fix: correct USB connection check & settings reset condition
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user