fix: correct USB connection check & settings reset condition

This commit is contained in:
2026-06-11 20:39:59 +02:00
parent 427af1f947
commit cfa77b7469
2 changed files with 8 additions and 10 deletions
+1 -1
View File
@@ -655,7 +655,7 @@ export default function CameraScreen({
{/* Camera Preview Background */}
<View style={styles.previewContainer}>
<View style={styles.cameraWrapper}>
{!isObscured && isUsbConnected && !useFrontCamera ? (
{!isObscured && Platform.OS === 'android' && !useFrontCamera ? (
<UsbCameraView
ref={usbCameraRef}
style={StyleSheet.absoluteFill}
+7 -9
View File
@@ -69,15 +69,13 @@ export async function loadSettings(): Promise<AppSettings> {
const parsed = JSON.parse(content);
// Reset to defaults if the app installation/update time has changed
// Allow a small drift margin (e.g. 5 seconds) just in case
if (parsed.appLastUpdate && currentUpdateTime) {
if (Math.abs(parsed.appLastUpdate - currentUpdateTime) > 5000) {
console.log(`App update detected. Resetting settings to default.`);
const defaults = { ...DEFAULT_SETTINGS, appLastUpdate: currentUpdateTime };
// Instantly save the new default settings to disk so they persist!
await saveSettings(defaults);
return defaults;
}
// Also reset if appLastUpdate is completely missing (updating from older version)
if (!parsed.appLastUpdate || (currentUpdateTime && Math.abs(parsed.appLastUpdate - currentUpdateTime) > 5000)) {
console.log(`App update detected. Resetting settings to default.`);
const defaults = { ...DEFAULT_SETTINGS, appLastUpdate: currentUpdateTime || Date.now() };
// Instantly save the new default settings to disk so they persist!
await saveSettings(defaults);
return defaults;
}
return { ...DEFAULT_SETTINGS, ...parsed, appLastUpdate: currentUpdateTime };