refactor: sidebar
This commit is contained in:
parent
21663711f8
commit
057de9595b
13 changed files with 110 additions and 44 deletions
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue