feat: default to the new mobile layout
Make the new mobile layout the default when no preference is stored, and relabel the legacy 'default' option as Old (localized as Previous/older where it reads better) while keeping its stored value for backwards compatibility.
This commit is contained in:
@@ -3,18 +3,20 @@ export type MobileLayoutPreference = 'default' | 'new';
|
||||
const MOBILE_LAYOUT_PREFERENCE_KEY = 'openchamber-mobile-layout';
|
||||
|
||||
export const normalizeMobileLayoutPreference = (value: unknown): MobileLayoutPreference => {
|
||||
return value === 'new' ? 'new' : 'default';
|
||||
// 'new' is the default; only an explicit 'default' (the legacy/"Old" layout)
|
||||
// opts out of it.
|
||||
return value === 'default' ? 'default' : 'new';
|
||||
};
|
||||
|
||||
export const getStoredMobileLayoutPreference = (): MobileLayoutPreference => {
|
||||
if (typeof window === 'undefined') {
|
||||
return 'default';
|
||||
return 'new';
|
||||
}
|
||||
|
||||
try {
|
||||
return normalizeMobileLayoutPreference(window.localStorage.getItem(MOBILE_LAYOUT_PREFERENCE_KEY));
|
||||
} catch {
|
||||
return 'default';
|
||||
return 'new';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user