2026-06-02 00:43:05 +03:00
|
|
|
export type MobileLayoutPreference = 'default' | 'new';
|
|
|
|
|
|
|
|
|
|
const MOBILE_LAYOUT_PREFERENCE_KEY = 'openchamber-mobile-layout';
|
|
|
|
|
|
2026-06-26 19:27:53 +03:00
|
|
|
const normalizeMobileLayoutPreference = (value: unknown): MobileLayoutPreference => {
|
2026-06-02 21:01:43 +03:00
|
|
|
// 'new' is the default; only an explicit 'default' (the legacy/"Old" layout)
|
|
|
|
|
// opts out of it.
|
|
|
|
|
return value === 'default' ? 'default' : 'new';
|
2026-06-02 00:43:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getStoredMobileLayoutPreference = (): MobileLayoutPreference => {
|
|
|
|
|
if (typeof window === 'undefined') {
|
2026-06-02 21:01:43 +03:00
|
|
|
return 'new';
|
2026-06-02 00:43:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
return normalizeMobileLayoutPreference(window.localStorage.getItem(MOBILE_LAYOUT_PREFERENCE_KEY));
|
|
|
|
|
} catch {
|
2026-06-02 21:01:43 +03:00
|
|
|
return 'new';
|
2026-06-02 00:43:05 +03:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const setStoredMobileLayoutPreference = (value: MobileLayoutPreference): boolean => {
|
|
|
|
|
if (typeof window === 'undefined') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
window.localStorage.setItem(MOBILE_LAYOUT_PREFERENCE_KEY, value);
|
|
|
|
|
return true;
|
|
|
|
|
} catch {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|