feat: add toggle to hide untrusted posts (#435)
This commit is contained in:
committed by
Cody Tseng
parent
9da5e6663e
commit
98bf906916
@@ -28,6 +28,7 @@ class LocalStorageService {
|
||||
private autoplay: boolean = true
|
||||
private hideUntrustedInteractions: boolean = false
|
||||
private hideUntrustedNotifications: boolean = false
|
||||
private hideUntrustedNotes: boolean = false
|
||||
private translationServiceConfigMap: Record<string, TTranslationServiceConfig> = {}
|
||||
|
||||
constructor() {
|
||||
@@ -95,8 +96,9 @@ class LocalStorageService {
|
||||
window.localStorage.getItem(StorageKey.MEDIA_UPLOAD_SERVICE) ?? DEFAULT_NIP_96_SERVICE
|
||||
|
||||
this.autoplay = window.localStorage.getItem(StorageKey.AUTOPLAY) !== 'false'
|
||||
this.hideUntrustedNotes = window.localStorage.getItem(StorageKey.HIDE_UNTRUSTED_NOTES) === 'true'
|
||||
|
||||
const hideUntrustedEvents =
|
||||
const hideUntrustedNotes =
|
||||
window.localStorage.getItem(StorageKey.HIDE_UNTRUSTED_EVENTS) === 'true'
|
||||
const storedHideUntrustedInteractions = window.localStorage.getItem(
|
||||
StorageKey.HIDE_UNTRUSTED_INTERACTIONS
|
||||
@@ -106,10 +108,11 @@ class LocalStorageService {
|
||||
)
|
||||
this.hideUntrustedInteractions = storedHideUntrustedInteractions
|
||||
? storedHideUntrustedInteractions === 'true'
|
||||
: hideUntrustedEvents
|
||||
: hideUntrustedNotes
|
||||
this.hideUntrustedNotifications = storedHideUntrustedNotifications
|
||||
? storedHideUntrustedNotifications === 'true'
|
||||
: hideUntrustedEvents
|
||||
: hideUntrustedNotes
|
||||
this.hideUntrustedNotes = hideUntrustedNotes
|
||||
|
||||
const translationServiceConfigMapStr = window.localStorage.getItem(
|
||||
StorageKey.TRANSLATION_SERVICE_CONFIG_MAP
|
||||
@@ -301,6 +304,18 @@ class LocalStorageService {
|
||||
)
|
||||
}
|
||||
|
||||
getHideUntrustedNotes() {
|
||||
return this.hideUntrustedNotes
|
||||
}
|
||||
|
||||
setHideUntrustedNotes(hideUntrustedNotes: boolean) {
|
||||
this.hideUntrustedNotes = hideUntrustedNotes
|
||||
window.localStorage.setItem(
|
||||
StorageKey.HIDE_UNTRUSTED_NOTES,
|
||||
hideUntrustedNotes.toString()
|
||||
)
|
||||
}
|
||||
|
||||
getTranslationServiceConfig(pubkey?: string | null) {
|
||||
return this.translationServiceConfigMap[pubkey ?? '_'] ?? { service: 'jumble' }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user