feat: add option to disable filtering for onion relays

This commit is contained in:
codytseng 2025-11-15 13:58:20 +08:00
parent 606f9af1ba
commit 5ba5c26fcd
25 changed files with 98 additions and 36 deletions

View file

@ -10,6 +10,7 @@ import {
} from '@/constants'
import { isSameAccount } from '@/lib/account'
import { randomString } from '@/lib/random'
import { isTorBrowser } from '@/lib/utils'
import {
TAccount,
TAccountPointer,
@ -54,6 +55,7 @@ class LocalStorageService {
private primaryColor: TPrimaryColor = 'DEFAULT'
private enableSingleColumnLayout: boolean = true
private faviconUrlTemplate: string = DEFAULT_FAVICON_URL_TEMPLATE
private filterOutOnionRelays: boolean = !isTorBrowser()
constructor() {
if (!LocalStorageService.instance) {
@ -210,6 +212,11 @@ class LocalStorageService {
this.faviconUrlTemplate =
window.localStorage.getItem(StorageKey.FAVICON_URL_TEMPLATE) ?? DEFAULT_FAVICON_URL_TEMPLATE
const filterOutOnionRelaysStr = window.localStorage.getItem(StorageKey.FILTER_OUT_ONION_RELAYS)
if (filterOutOnionRelaysStr) {
this.filterOutOnionRelays = filterOutOnionRelaysStr !== 'false'
}
// Clean up deprecated data
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
window.localStorage.removeItem(StorageKey.ACCOUNT_FOLLOW_LIST_EVENT_MAP)
@ -529,6 +536,15 @@ class LocalStorageService {
this.faviconUrlTemplate = template
window.localStorage.setItem(StorageKey.FAVICON_URL_TEMPLATE, template)
}
getFilterOutOnionRelays() {
return this.filterOutOnionRelays
}
setFilterOutOnionRelays(filterOut: boolean) {
this.filterOutOnionRelays = filterOut
window.localStorage.setItem(StorageKey.FILTER_OUT_ONION_RELAYS, filterOut.toString())
}
}
const instance = new LocalStorageService()