feat: add photo selection reel for collages and app version reset
This commit is contained in:
@@ -2,7 +2,10 @@ import { File, Paths } from 'expo-file-system';
|
||||
import * as FileSystem from 'expo-file-system/legacy';
|
||||
import { FRAMES } from '../data/frames';
|
||||
|
||||
export const APP_VERSION = 2; // Increment this whenever you want settings to reset on update
|
||||
|
||||
export interface AppSettings {
|
||||
appVersion: number;
|
||||
countdownDuration: number; // in seconds
|
||||
printerIp: string;
|
||||
adminPassword: string;
|
||||
@@ -30,6 +33,7 @@ export interface AppSettings {
|
||||
const settingsFile = new File(Paths.document, 'settings.json');
|
||||
|
||||
const DEFAULT_SETTINGS: AppSettings = {
|
||||
appVersion: APP_VERSION,
|
||||
countdownDuration: 3,
|
||||
printerIp: '192.168.1.100',
|
||||
adminPassword: '1234',
|
||||
@@ -55,6 +59,13 @@ export async function loadSettings(): Promise<AppSettings> {
|
||||
try {
|
||||
const content = await settingsFile.text();
|
||||
const parsed = JSON.parse(content);
|
||||
|
||||
// Reset to defaults if the app version has changed (app updated)
|
||||
if (parsed.appVersion !== APP_VERSION) {
|
||||
console.log(`Settings version mismatch (old: ${parsed.appVersion}, new: ${APP_VERSION}). Resetting to default.`);
|
||||
return DEFAULT_SETTINGS;
|
||||
}
|
||||
|
||||
return { ...DEFAULT_SETTINGS, ...parsed };
|
||||
} catch (e) {
|
||||
console.error('Failed to load settings, using defaults:', e);
|
||||
|
||||
Reference in New Issue
Block a user