Merge branch 'dev' into feature/funk

This commit is contained in:
Alec Schitzkat
2026-08-08 18:21:43 +02:00
14 changed files with 1227 additions and 45 deletions
+30
View File
@@ -13,6 +13,9 @@ describe('preferences', () => {
version: 1,
settings: {
appearanceMode: 'light',
bluetoothEnabled: false,
cellularEnabled: false,
focusMode: true,
notificationVolume: 45,
notificationDurationSeconds: 14,
notifications: {
@@ -20,11 +23,17 @@ describe('preferences', () => {
clock: { enabled: false, sounds: false },
},
phoneScale: 110,
rotationLocked: true,
screenBrightness: 64,
wallpaper: 'ember',
wifiEnabled: false,
},
}),
)
expect(value.settings.appearanceMode).toBe('light')
expect(value.settings.bluetoothEnabled).toBe(false)
expect(value.settings.cellularEnabled).toBe(false)
expect(value.settings.focusMode).toBe(true)
expect(value.settings.notificationVolume).toBe(45)
expect(value.settings.notificationDurationSeconds).toBe(14)
expect(value.settings.notifications.messages).toEqual({
@@ -40,7 +49,10 @@ describe('preferences', () => {
sounds: true,
})
expect(value.settings.phoneScale).toBe(110)
expect(value.settings.rotationLocked).toBe(true)
expect(value.settings.screenBrightness).toBe(64)
expect(value.settings.wallpaper).toBe('ember')
expect(value.settings.wifiEnabled).toBe(false)
})
it('clamps ranges and rejects unknown choices', () => {
@@ -54,6 +66,7 @@ describe('preferences', () => {
notificationDurationSeconds: 100,
phoneScale: 500,
ringtoneVolume: 120,
screenBrightness: -20,
},
}),
)
@@ -64,5 +77,22 @@ describe('preferences', () => {
expect(value.settings.notificationDurationSeconds).toBe(30)
expect(value.settings.phoneScale).toBe(150)
expect(value.settings.ringtoneVolume).toBe(100)
expect(value.settings.screenBrightness).toBe(10)
})
it('adds safe control center defaults to legacy version one preferences', () => {
const value = parsePhonePreferences(
JSON.stringify({ version: 1, settings: { airplaneMode: true } }),
)
expect(value.settings).toMatchObject({
airplaneMode: true,
bluetoothEnabled: true,
cellularEnabled: true,
focusMode: false,
rotationLocked: false,
screenBrightness: 100,
wifiEnabled: true,
})
})
})
+32
View File
@@ -30,6 +30,9 @@ export type PhonePreferencesV1 = {
settings: {
airplaneMode: boolean
appearanceMode: AppearanceMode
bluetoothEnabled: boolean
cellularEnabled: boolean
focusMode: boolean
frame: PhoneFrameId
notificationSound: NotificationSoundId
notificationDurationSeconds: number
@@ -38,8 +41,11 @@ export type PhonePreferencesV1 = {
phoneScale: number
ringtone: RingtoneId
ringtoneVolume: number
rotationLocked: boolean
screenBrightness: number
streamerMode: boolean
wallpaper: WallpaperId
wifiEnabled: boolean
}
version: 1
}
@@ -79,6 +85,9 @@ export const DEFAULT_PHONE_PREFERENCES: PhonePreferencesV1 = {
settings: {
airplaneMode: false,
appearanceMode: 'automatic',
bluetoothEnabled: true,
cellularEnabled: true,
focusMode: false,
frame: 'black',
notificationSound: 'chime',
notificationDurationSeconds: 10,
@@ -87,8 +96,11 @@ export const DEFAULT_PHONE_PREFERENCES: PhonePreferencesV1 = {
phoneScale: 100,
ringtone: 'skyline',
ringtoneVolume: 80,
rotationLocked: false,
screenBrightness: 100,
streamerMode: false,
wallpaper: 'midnight',
wifiEnabled: true,
},
version: 1,
}
@@ -164,6 +176,15 @@ export function parsePhonePreferences(raw: string | null): PhonePreferencesV1 {
APPEARANCE_MODE_IDS,
defaults.appearanceMode,
),
bluetoothEnabled: readBoolean(
settings.bluetoothEnabled,
defaults.bluetoothEnabled,
),
cellularEnabled: readBoolean(
settings.cellularEnabled,
defaults.cellularEnabled,
),
focusMode: readBoolean(settings.focusMode, defaults.focusMode),
frame: readChoice(settings.frame, PHONE_FRAME_IDS, defaults.frame),
notificationSound: readChoice(
settings.notificationSound,
@@ -200,12 +221,23 @@ export function parsePhonePreferences(raw: string | null): PhonePreferencesV1 {
0,
100,
),
rotationLocked: readBoolean(
settings.rotationLocked,
defaults.rotationLocked,
),
screenBrightness: readNumber(
settings.screenBrightness,
defaults.screenBrightness,
10,
100,
),
streamerMode: readBoolean(settings.streamerMode, defaults.streamerMode),
wallpaper: readChoice(
settings.wallpaper,
WALLPAPER_IDS,
defaults.wallpaper,
),
wifiEnabled: readBoolean(settings.wifiEnabled, defaults.wifiEnabled),
},
version: 1,
}