55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import { EVENTS } from "./lib/event";
|
|
import { ContentService } from "./services/content.service";
|
|
|
|
const port = chrome.runtime.connect({ name: "message" });
|
|
|
|
const contentService = new ContentService(port);
|
|
|
|
port.onMessage.addListener((msg: IMsg<any>) => {
|
|
console.log({ msg });
|
|
|
|
// Set height input chat tager cho nó ra dễ click
|
|
// contentService.fixedHeightChatInput();
|
|
|
|
if (msg.type !== "socket") {
|
|
return;
|
|
}
|
|
|
|
switch (msg.event) {
|
|
case EVENTS.GET_CONVERSATIONS: {
|
|
contentService.getConversations(msg);
|
|
break;
|
|
}
|
|
|
|
case EVENTS.GET_CONVERSATION: {
|
|
contentService.getConversation(msg);
|
|
break;
|
|
}
|
|
|
|
case EVENTS.SEND_MESSAGE: {
|
|
contentService.sendMessage(msg);
|
|
break;
|
|
}
|
|
|
|
case EVENTS.REPLY_MESSAGE: {
|
|
contentService.replyMessage(msg);
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
// SYNC CONVERSASIONS (INTERVAL)
|
|
contentService.startSyncConversations();
|
|
|
|
// AUTO SYNC MESAGE PREFIX (INTERNAL)
|
|
contentService.autoSyncConversationPrefixMessages();
|
|
|
|
// setTimeout(async () => {
|
|
// const a = new TeamsChatService();
|
|
|
|
// const conversations = await a.handleGetConversations();
|
|
|
|
// console.log({ conversations });
|
|
// }, 10000);
|