feat: add option to disable filtering for onion relays
This commit is contained in:
parent
606f9af1ba
commit
5ba5c26fcd
25 changed files with 98 additions and 36 deletions
|
|
@ -31,6 +31,7 @@ import {
|
|||
} from 'nostr-tools'
|
||||
import { AbstractRelay } from 'nostr-tools/abstract-relay'
|
||||
import indexedDb from './indexed-db.service'
|
||||
import storage from './local-storage.service'
|
||||
|
||||
type TTimelineRef = [string, number]
|
||||
|
||||
|
|
@ -1131,7 +1132,7 @@ class ClientService extends EventTarget {
|
|||
|
||||
return relayEvents.map((event) => {
|
||||
if (event) {
|
||||
return getRelayListFromEvent(event)
|
||||
return getRelayListFromEvent(event, storage.getFilterOutOnionRelays())
|
||||
}
|
||||
return {
|
||||
write: BIG_RELAY_URLS,
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue