feat: add autoplay switch

This commit is contained in:
codytseng
2025-05-08 23:24:57 +08:00
parent aa24ad83e5
commit 7b882c72cb
21 changed files with 228 additions and 81 deletions

View File

@@ -24,6 +24,7 @@ class LocalStorageService {
private quickZap: boolean = false
private accountFeedInfoMap: Record<string, TFeedInfo | undefined> = {}
private mediaUploadService: string = DEFAULT_NIP_96_SERVICE
private autoplay: boolean = true
constructor() {
if (!LocalStorageService.instance) {
@@ -89,6 +90,8 @@ class LocalStorageService {
this.mediaUploadService =
window.localStorage.getItem(StorageKey.MEDIA_UPLOAD_SERVICE) ?? DEFAULT_NIP_96_SERVICE
this.autoplay = window.localStorage.getItem(StorageKey.AUTOPLAY) !== 'false'
// Clean up deprecated data
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
window.localStorage.removeItem(StorageKey.ACCOUNT_FOLLOW_LIST_EVENT_MAP)
@@ -235,6 +238,15 @@ class LocalStorageService {
this.mediaUploadService = service
window.localStorage.setItem(StorageKey.MEDIA_UPLOAD_SERVICE, service)
}
getAutoplay() {
return this.autoplay
}
setAutoplay(autoplay: boolean) {
this.autoplay = autoplay
window.localStorage.setItem(StorageKey.AUTOPLAY, autoplay.toString())
}
}
const instance = new LocalStorageService()