From 50eebbfe0fc949748f26605033427580f363ad07 Mon Sep 17 00:00:00 2001 From: Shusui MOYATANI Date: Thu, 22 Feb 2024 21:55:19 +0900 Subject: [PATCH] fix: mute keywords condition --- src/core/useConfig.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/useConfig.ts b/src/core/useConfig.ts index 922efb3..9d553d0 100644 --- a/src/core/useConfig.ts +++ b/src/core/useConfig.ts @@ -222,10 +222,15 @@ const useConfig = (): UseConfig => { const mutedPubkeySet = createMemo(() => new Set(config.mutedPubkeys)); const isPubkeyMuted = (pubkey: string) => mutedPubkeySet().has(pubkey); - const mutedKeywordsRegex = createMemo(() => asCaseInsensitive(wordsRegex(config.mutedKeywords))); + const mutedKeywordsRegex = createMemo(() => { + if (config.mutedKeywords.length === 0) return null; + return asCaseInsensitive(wordsRegex(config.mutedKeywords)); + }); const hasMutedKeyword = (event: NostrEvent) => { if (event.kind === Kind.ShortTextNote) { - return mutedKeywordsRegex().test(event.content); + const regex = mutedKeywordsRegex(); + if (regex == null) return false; + return regex.test(event.content); } return false; };