From faa7298f89b43634c1e7fc065aa9c583c7ed5049 Mon Sep 17 00:00:00 2001 From: codytseng Date: Sat, 1 Feb 2025 14:45:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/storage.service.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/services/storage.service.ts b/src/services/storage.service.ts index 7acc202a..060ff391 100644 --- a/src/services/storage.service.ts +++ b/src/services/storage.service.ts @@ -73,8 +73,12 @@ class StorageService { this.accounts = accountsStr ? JSON.parse(accountsStr) : [] const currentAccountStr = window.localStorage.getItem(StorageKey.CURRENT_ACCOUNT) this.currentAccount = currentAccountStr ? JSON.parse(currentAccountStr) : null - const feedTypeStr = window.localStorage.getItem(StorageKey.FEED_TYPE) - this.feedType = feedTypeStr ? JSON.parse(feedTypeStr) : 'relays' + const feedType = window.localStorage.getItem(StorageKey.FEED_TYPE) + if (feedType && ['following', 'relays'].includes(feedType)) { + this.feedType = feedType as 'following' | 'relays' + } else { + this.feedType = 'relays' + } const noteListModeStr = window.localStorage.getItem(StorageKey.NOTE_LIST_MODE) this.noteListMode = noteListModeStr && ['posts', 'postsAndReplies', 'pictures'].includes(noteListModeStr) @@ -136,8 +140,7 @@ class StorageService { this.activeRelaySetId = activeRelaySetId } else { this.relaySets = JSON.parse(relaySetsStr) - const activeRelaySetIdStr = window.localStorage.getItem(StorageKey.ACTIVE_RELAY_SET_ID) - this.activeRelaySetId = activeRelaySetIdStr ? JSON.parse(activeRelaySetIdStr) : null + this.activeRelaySetId = window.localStorage.getItem(StorageKey.ACTIVE_RELAY_SET_ID) ?? null } } @@ -157,10 +160,7 @@ class StorageService { setActiveRelaySetId(id: string | null) { this.activeRelaySetId = id if (id) { - window.localStorage.setItem( - StorageKey.ACTIVE_RELAY_SET_ID, - JSON.stringify(this.activeRelaySetId) - ) + window.localStorage.setItem(StorageKey.ACTIVE_RELAY_SET_ID, id) } else { window.localStorage.removeItem(StorageKey.ACTIVE_RELAY_SET_ID) } @@ -172,7 +172,7 @@ class StorageService { setFeedType(feedType: TFeedType) { this.feedType = feedType - window.localStorage.setItem(StorageKey.FEED_TYPE, JSON.stringify(this.feedType)) + window.localStorage.setItem(StorageKey.FEED_TYPE, this.feedType) } getThemeSetting() {