You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
import storage from '@/services/local-storage.service' |
|
import { TNotificationStyle } from '@/types' |
|
import { createContext, useContext, useState } from 'react' |
|
|
|
type TUserPreferencesContext = { |
|
notificationListStyle: TNotificationStyle |
|
updateNotificationListStyle: (style: TNotificationStyle) => void |
|
showRecommendedRelaysPanel: boolean |
|
updateShowRecommendedRelaysPanel: (show: boolean) => void |
|
} |
|
|
|
const UserPreferencesContext = createContext<TUserPreferencesContext | undefined>(undefined) |
|
|
|
export const useUserPreferences = () => { |
|
const context = useContext(UserPreferencesContext) |
|
if (!context) { |
|
throw new Error('useUserPreferences must be used within a UserPreferencesProvider') |
|
} |
|
return context |
|
} |
|
|
|
export function UserPreferencesProvider({ children }: { children: React.ReactNode }) { |
|
const [notificationListStyle, setNotificationListStyle] = useState( |
|
storage.getNotificationListStyle() |
|
) |
|
// DEPRECATED: Double-panel functionality removed for technical debt reduction |
|
// Keeping for backward compatibility in case we miss any references |
|
const [showRecommendedRelaysPanel] = useState(false) |
|
|
|
// DEPRECATED: Mobile panel forcing removed - double-panel functionality disabled |
|
|
|
const updateNotificationListStyle = (style: TNotificationStyle) => { |
|
setNotificationListStyle(style) |
|
storage.setNotificationListStyle(style) |
|
} |
|
|
|
// DEPRECATED: Double-panel functionality disabled - always returns false |
|
const updateShowRecommendedRelaysPanel = (_show: boolean) => { |
|
// No-op: double-panel functionality has been removed |
|
} |
|
|
|
return ( |
|
<UserPreferencesContext.Provider |
|
value={{ |
|
notificationListStyle, |
|
updateNotificationListStyle, |
|
showRecommendedRelaysPanel, |
|
updateShowRecommendedRelaysPanel |
|
}} |
|
> |
|
{children} |
|
</UserPreferencesContext.Provider> |
|
) |
|
}
|
|
|