fix: correct USB connection check & settings reset condition
This commit is contained in:
@@ -655,7 +655,7 @@ export default function CameraScreen({
|
|||||||
{/* Camera Preview Background */}
|
{/* Camera Preview Background */}
|
||||||
<View style={styles.previewContainer}>
|
<View style={styles.previewContainer}>
|
||||||
<View style={styles.cameraWrapper}>
|
<View style={styles.cameraWrapper}>
|
||||||
{!isObscured && isUsbConnected && !useFrontCamera ? (
|
{!isObscured && Platform.OS === 'android' && !useFrontCamera ? (
|
||||||
<UsbCameraView
|
<UsbCameraView
|
||||||
ref={usbCameraRef}
|
ref={usbCameraRef}
|
||||||
style={StyleSheet.absoluteFill}
|
style={StyleSheet.absoluteFill}
|
||||||
|
|||||||
@@ -69,16 +69,14 @@ export async function loadSettings(): Promise<AppSettings> {
|
|||||||
const parsed = JSON.parse(content);
|
const parsed = JSON.parse(content);
|
||||||
|
|
||||||
// Reset to defaults if the app installation/update time has changed
|
// Reset to defaults if the app installation/update time has changed
|
||||||
// Allow a small drift margin (e.g. 5 seconds) just in case
|
// Also reset if appLastUpdate is completely missing (updating from older version)
|
||||||
if (parsed.appLastUpdate && currentUpdateTime) {
|
if (!parsed.appLastUpdate || (currentUpdateTime && Math.abs(parsed.appLastUpdate - currentUpdateTime) > 5000)) {
|
||||||
if (Math.abs(parsed.appLastUpdate - currentUpdateTime) > 5000) {
|
|
||||||
console.log(`App update detected. Resetting settings to default.`);
|
console.log(`App update detected. Resetting settings to default.`);
|
||||||
const defaults = { ...DEFAULT_SETTINGS, appLastUpdate: currentUpdateTime };
|
const defaults = { ...DEFAULT_SETTINGS, appLastUpdate: currentUpdateTime || Date.now() };
|
||||||
// Instantly save the new default settings to disk so they persist!
|
// Instantly save the new default settings to disk so they persist!
|
||||||
await saveSettings(defaults);
|
await saveSettings(defaults);
|
||||||
return defaults;
|
return defaults;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return { ...DEFAULT_SETTINGS, ...parsed, appLastUpdate: currentUpdateTime };
|
return { ...DEFAULT_SETTINGS, ...parsed, appLastUpdate: currentUpdateTime };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user