feat: add toggle to show NSFW content by default
This commit is contained in:
parent
352eecc416
commit
cb2ad30b1d
23 changed files with 108 additions and 55 deletions
|
|
@ -32,6 +32,7 @@ class LocalStorageService {
|
|||
private hideUntrustedNotes: boolean = false
|
||||
private translationServiceConfigMap: Record<string, TTranslationServiceConfig> = {}
|
||||
private mediaUploadServiceConfigMap: Record<string, TMediaUploadServiceConfig> = {}
|
||||
private defaultShowNsfw: boolean = false
|
||||
|
||||
constructor() {
|
||||
if (!LocalStorageService.instance) {
|
||||
|
|
@ -133,6 +134,9 @@ class LocalStorageService {
|
|||
this.mediaUploadServiceConfigMap = JSON.parse(mediaUploadServiceConfigMapStr)
|
||||
}
|
||||
|
||||
const defaultShowNsfwStr = window.localStorage.getItem(StorageKey.DEFAULT_SHOW_NSFW)
|
||||
this.defaultShowNsfw = defaultShowNsfwStr === 'true'
|
||||
|
||||
// Clean up deprecated data
|
||||
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
|
||||
window.localStorage.removeItem(StorageKey.ACCOUNT_FOLLOW_LIST_EVENT_MAP)
|
||||
|
|
@ -347,6 +351,15 @@ class LocalStorageService {
|
|||
)
|
||||
return config
|
||||
}
|
||||
|
||||
getDefaultShowNsfw() {
|
||||
return this.defaultShowNsfw
|
||||
}
|
||||
|
||||
setDefaultShowNsfw(defaultShowNsfw: boolean) {
|
||||
this.defaultShowNsfw = defaultShowNsfw
|
||||
window.localStorage.setItem(StorageKey.DEFAULT_SHOW_NSFW, defaultShowNsfw.toString())
|
||||
}
|
||||
}
|
||||
|
||||
const instance = new LocalStorageService()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue