+
-
-
-
-
-
-
-
-
-
-
-
+ {sidebarCollapse ? (
+
+
+
+ ) : (
+
+
+
+ )}
+
+
+
+
+
+
+
-
+
+
)
}
diff --git a/src/constants.ts b/src/constants.ts
index 1cf525ac..5b7b46f3 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -48,6 +48,7 @@ export const StorageKey = {
NOTIFICATION_LIST_STYLE: 'notificationListStyle',
MEDIA_AUTO_LOAD_POLICY: 'mediaAutoLoadPolicy',
SHOWN_CREATE_WALLET_GUIDE_TOAST_PUBKEYS: 'shownCreateWalletGuideToastPubkeys',
+ SIDEBAR_COLLAPSE: 'sidebarCollapse',
MEDIA_UPLOAD_SERVICE: 'mediaUploadService', // deprecated
HIDE_UNTRUSTED_EVENTS: 'hideUntrustedEvents', // deprecated
ACCOUNT_RELAY_LIST_EVENT_MAP: 'accountRelayListEventMap', // deprecated
diff --git a/src/providers/UserPreferencesProvider.tsx b/src/providers/UserPreferencesProvider.tsx
index e82d09d3..cc2292ea 100644
--- a/src/providers/UserPreferencesProvider.tsx
+++ b/src/providers/UserPreferencesProvider.tsx
@@ -8,6 +8,9 @@ type TUserPreferencesContext = {
muteMedia: boolean
updateMuteMedia: (mute: boolean) => void
+
+ sidebarCollapse: boolean
+ updateSidebarCollapse: (collapse: boolean) => void
}
const UserPreferencesContext = createContext
(undefined)
@@ -25,19 +28,27 @@ export function UserPreferencesProvider({ children }: { children: React.ReactNod
storage.getNotificationListStyle()
)
const [muteMedia, setMuteMedia] = useState(true)
+ const [sidebarCollapse, setSidebarCollapse] = useState(storage.getSidebarCollapse())
const updateNotificationListStyle = (style: TNotificationStyle) => {
setNotificationListStyle(style)
storage.setNotificationListStyle(style)
}
+ const updateSidebarCollapse = (collapse: boolean) => {
+ setSidebarCollapse(collapse)
+ storage.setSidebarCollapse(collapse)
+ }
+
return (
{children}
diff --git a/src/services/local-storage.service.ts b/src/services/local-storage.service.ts
index c04f3954..2522b1dc 100644
--- a/src/services/local-storage.service.ts
+++ b/src/services/local-storage.service.ts
@@ -48,6 +48,7 @@ class LocalStorageService {
private notificationListStyle: TNotificationStyle = NOTIFICATION_LIST_STYLE.DETAILED
private mediaAutoLoadPolicy: TMediaAutoLoadPolicy = MEDIA_AUTO_LOAD_POLICY.ALWAYS
private shownCreateWalletGuideToastPubkeys: Set = new Set()
+ private sidebarCollapse: boolean = false
constructor() {
if (!LocalStorageService.instance) {
@@ -193,6 +194,8 @@ class LocalStorageService {
? new Set(JSON.parse(shownCreateWalletGuideToastPubkeysStr))
: new Set()
+ this.sidebarCollapse = window.localStorage.getItem(StorageKey.SIDEBAR_COLLAPSE) === 'true'
+
// Clean up deprecated data
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
window.localStorage.removeItem(StorageKey.ACCOUNT_FOLLOW_LIST_EVENT_MAP)
@@ -476,6 +479,15 @@ class LocalStorageService {
JSON.stringify(Array.from(this.shownCreateWalletGuideToastPubkeys))
)
}
+
+ getSidebarCollapse() {
+ return this.sidebarCollapse
+ }
+
+ setSidebarCollapse(collapse: boolean) {
+ this.sidebarCollapse = collapse
+ window.localStorage.setItem(StorageKey.SIDEBAR_COLLAPSE, collapse.toString())
+ }
}
const instance = new LocalStorageService()