feat: muted words

This commit is contained in:
codytseng 2026-01-08 22:53:11 +08:00
parent 3c74c8c5db
commit 603bd35b4a
25 changed files with 282 additions and 87 deletions

View file

@ -66,6 +66,7 @@ class LocalStorageService {
private nsfwDisplayPolicy: TNsfwDisplayPolicy = NSFW_DISPLAY_POLICY.HIDE_CONTENT
private minTrustScore: number = 40
private defaultRelayUrls: string[] = BIG_RELAY_URLS
private mutedWords: string[] = []
constructor() {
if (!LocalStorageService.instance) {
@ -293,6 +294,18 @@ class LocalStorageService {
}
}
const mutedWordsStr = window.localStorage.getItem(StorageKey.MUTED_WORDS)
if (mutedWordsStr) {
try {
const words = JSON.parse(mutedWordsStr)
if (Array.isArray(words) && words.every((word) => typeof word === 'string')) {
this.mutedWords = words
}
} catch {
// Invalid JSON, use default
}
}
// Clean up deprecated data
window.localStorage.removeItem(StorageKey.PINNED_PUBKEYS)
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
@ -640,6 +653,15 @@ class LocalStorageService {
this.defaultRelayUrls = urls
window.localStorage.setItem(StorageKey.DEFAULT_RELAY_URLS, JSON.stringify(urls))
}
getMutedWords() {
return this.mutedWords
}
setMutedWords(words: string[]) {
this.mutedWords = words
window.localStorage.setItem(StorageKey.MUTED_WORDS, JSON.stringify(this.mutedWords))
}
}
const instance = new LocalStorageService()