feat: support change media upload service

This commit is contained in:
codytseng 2025-04-08 14:23:16 +08:00
parent 2e552c356c
commit bc0fa7f528
11 changed files with 198 additions and 41 deletions

View file

@ -1,4 +1,4 @@
import { StorageKey } from '@/constants'
import { DEFAULT_NIP_96_SERVICE, StorageKey } from '@/constants'
import { isSameAccount } from '@/lib/account'
import { randomString } from '@/lib/random'
import {
@ -23,6 +23,7 @@ class LocalStorageService {
private defaultZapComment: string = 'Zap!'
private quickZap: boolean = false
private accountFeedInfoMap: Record<string, TFeedInfo | undefined> = {}
private mediaUploadService: string = DEFAULT_NIP_96_SERVICE
constructor() {
if (!LocalStorageService.instance) {
@ -85,6 +86,9 @@ class LocalStorageService {
window.localStorage.getItem(StorageKey.ACCOUNT_FEED_INFO_MAP) ?? '{}'
this.accountFeedInfoMap = JSON.parse(accountFeedInfoMapStr)
this.mediaUploadService =
window.localStorage.getItem(StorageKey.MEDIA_UPLOAD_SERVICE) ?? DEFAULT_NIP_96_SERVICE
// Clean up deprecated data
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
window.localStorage.removeItem(StorageKey.ACCOUNT_FOLLOW_LIST_EVENT_MAP)
@ -222,6 +226,15 @@ class LocalStorageService {
JSON.stringify(this.accountFeedInfoMap)
)
}
getMediaUploadService() {
return this.mediaUploadService
}
setMediaUploadService(service: string) {
this.mediaUploadService = service
window.localStorage.setItem(StorageKey.MEDIA_UPLOAD_SERVICE, service)
}
}
const instance = new LocalStorageService()