From 9445d1c24224de675a2529d776c91eb06b299ee8 Mon Sep 17 00:00:00 2001 From: tai-cha Date: Tue, 6 May 2025 11:54:54 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E3=81=AAglobalThis?= =?UTF-8?q?=E5=88=A9=E7=94=A8=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/utility/check-word-mute.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/utility/check-word-mute.ts b/packages/frontend/src/utility/check-word-mute.ts index 3af5f1e221..1795f49c62 100644 --- a/packages/frontend/src/utility/check-word-mute.ts +++ b/packages/frontend/src/utility/check-word-mute.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import * as AhoCorasick from 'modern-ahocorasick'; +import { shallowRef } from 'vue'; import type * as Misskey from 'misskey-js'; import { $i } from '@/i.js'; @@ -13,11 +14,13 @@ type WordMuteInfo = false | { ahoCorasick: AhoCorasick.default; }; -type GlobalMisskeyWordMute = { +type WordMuteGroup = { soft: WordMuteInfo; hard: WordMuteInfo; }; +const builtWordMutes = shallowRef(undefined); + export function createWordMuteInfo(mutedWords: Array) : WordMuteInfo { if (mutedWords.length <= 0) return false; const normalTexts: string[] = []; @@ -58,12 +61,11 @@ function setWordMuteInfo(mutedWords: Array, hardMutedWords: A const soft = createWordMuteInfo(mutedWords); const hard = createWordMuteInfo(hardMutedWords); - globalThis._misskeyWordMute = { soft, hard }; + builtWordMutes.value = { soft, hard }; } -function getWordMuteInfo(): GlobalMisskeyWordMute | undefined { - if (!globalThis._misskeyWordMute) return undefined; - return globalThis._misskeyWordMute as unknown as GlobalMisskeyWordMute; +function getWordMuteInfo(): WordMuteGroup | undefined { + return builtWordMutes.value; } export function initWordMuteInfo(): void {