mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-17 14:04:21 +01:00
fix: mute keywords condition
This commit is contained in:
@@ -222,10 +222,15 @@ const useConfig = (): UseConfig => {
|
|||||||
const mutedPubkeySet = createMemo(() => new Set(config.mutedPubkeys));
|
const mutedPubkeySet = createMemo(() => new Set(config.mutedPubkeys));
|
||||||
const isPubkeyMuted = (pubkey: string) => mutedPubkeySet().has(pubkey);
|
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) => {
|
const hasMutedKeyword = (event: NostrEvent) => {
|
||||||
if (event.kind === Kind.ShortTextNote) {
|
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;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user