refactor: sidebar

This commit is contained in:
codytseng 2025-10-17 23:34:56 +08:00
parent 21663711f8
commit 057de9595b
13 changed files with 110 additions and 44 deletions

View file

@ -8,6 +8,9 @@ type TUserPreferencesContext = {
muteMedia: boolean
updateMuteMedia: (mute: boolean) => void
sidebarCollapse: boolean
updateSidebarCollapse: (collapse: boolean) => void
}
const UserPreferencesContext = createContext<TUserPreferencesContext | undefined>(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 (
<UserPreferencesContext.Provider
value={{
notificationListStyle,
updateNotificationListStyle,
muteMedia,
updateMuteMedia: setMuteMedia
updateMuteMedia: setMuteMedia,
sidebarCollapse,
updateSidebarCollapse: updateSidebarCollapse
}}
>
{children}