Skip to content

Commit

Permalink
refactor(eb-app-ui): sync pri/intercom.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
emrahcom committed Nov 10, 2024
1 parent 054694c commit d4c523e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions machines/eb-app-ui/home/ui/galaxy-dev/src/lib/pri/intercom.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getById, list } from "$lib/api";
import { isOver } from "$lib/common";
import type { IntercomMessage } from "$lib/types";
import type { IntercomMessage222 } from "$lib/types";

// -----------------------------------------------------------------------------
export function updateMessageList() {
const list: IntercomMessage[] = [];
const list: IntercomMessage222[] = [];

for (const key in globalThis.localStorage) {
try {
Expand All @@ -13,7 +13,7 @@ export function updateMessageList() {
const value = globalThis.localStorage.getItem(key);
if (!value) throw "empty message";

const parsedValue = JSON.parse(value) as IntercomMessage;
const parsedValue = JSON.parse(value) as IntercomMessage222;
list.push(parsedValue);
} catch {
globalThis.localStorage.removeItem(key);
Expand Down Expand Up @@ -42,7 +42,7 @@ export async function watchCall(msgId: string) {
}

// -----------------------------------------------------------------------------
function addCallMessage(msg: IntercomMessage) {
function addCallMessage(msg: IntercomMessage222) {
try {
const isExist = globalThis.localStorage.getItem(`msg-${msg.id}`);
if (isExist) return;
Expand Down Expand Up @@ -78,10 +78,11 @@ export async function intercomHandler() {
if (now - Number(checkedAt) > 3000) {
globalThis.localStorage.setItem("intercom_checked_at", String(now));

const messages: IntercomMessage[] = await list(
const messages: IntercomMessage222[] = await list(
"/api/pri/intercom/list",
10,
);

for (const msg of messages) {
if (msg.message_type === "call") {
addCallMessage(msg);
Expand Down

0 comments on commit d4c523e

Please sign in to comment.