diff options
Diffstat (limited to 'webAO/viewport')
| -rw-r--r-- | webAO/viewport/constants/defaultChatMsg.ts | 4 | ||||
| -rw-r--r-- | webAO/viewport/utils/handleICSpeaking.ts | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/webAO/viewport/constants/defaultChatMsg.ts b/webAO/viewport/constants/defaultChatMsg.ts index fa25b33..67c60b8 100644 --- a/webAO/viewport/constants/defaultChatMsg.ts +++ b/webAO/viewport/constants/defaultChatMsg.ts @@ -1,6 +1,8 @@ -import { UPDATE_INTERVAL } from "../../client"; import { ChatMsg } from "../interfaces/ChatMsg"; +// Define UPDATE_INTERVAL locally to avoid circular dependency +const UPDATE_INTERVAL = 60; + export const defaultChatMsg = { content: "", objection: 0, diff --git a/webAO/viewport/utils/handleICSpeaking.ts b/webAO/viewport/utils/handleICSpeaking.ts index b037e69..c0a9ae1 100644 --- a/webAO/viewport/utils/handleICSpeaking.ts +++ b/webAO/viewport/utils/handleICSpeaking.ts @@ -11,8 +11,17 @@ import { resizeChatbox } from "../../dom/resizeChatbox"; import transparentPng from "../../constants/transparentPng"; import { COLORS } from "../constants/colors"; import mlConfig from "../../utils/aoml"; +import request from "../../services/request"; -const attorneyMarkdown = mlConfig(AO_HOST); +let attorneyMarkdown: ReturnType<typeof mlConfig> | null = null; + +const initAttorneyMarkdown = async () => { + if (!attorneyMarkdown) { + const iniContent = await request(`${AO_HOST}themes/default/chat_config.ini`); + attorneyMarkdown = mlConfig(iniContent); + } + return attorneyMarkdown; +}; export let startFirstTickCheck: boolean; export const setStartFirstTickCheck = (val: boolean) => { @@ -337,9 +346,9 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { } try { - client.viewport.getChatmsg().parsed = await attorneyMarkdown.applyMarkdown( + const markdown = await initAttorneyMarkdown(); + client.viewport.getChatmsg().parsed = markdown.applyMarkdown( client.viewport.getChatmsg().content, - COLORS[client.viewport.getChatmsg().color], ); } catch (error) { |
