fix(mobile): gate watch directory on instance URL; skip auto-scan if unconfigured
Settings: watch directory field is hidden behind a warning if no instance URL is saved yet, making the dependency explicit before the user sets a path. Import: runAutoScan silently skips (no errors) when instance URL is missing; manualScan shows a single clear message instead of one failure per file.
This commit is contained in:
@@ -53,6 +53,8 @@ export default function ImportScreen() {
|
|||||||
if (isImporting.current) return;
|
if (isImporting.current) return;
|
||||||
const path = await getSetting(db, 'auto_import_path');
|
const path = await getSetting(db, 'auto_import_path');
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
|
const instanceUrl = await getSetting(db, 'instance_url');
|
||||||
|
if (!instanceUrl) return; // silently skip — engine can't be downloaded without an instance
|
||||||
|
|
||||||
const newFiles = await discoverNewFiles(db, path);
|
const newFiles = await discoverNewFiles(db, path);
|
||||||
if (newFiles.length === 0) return;
|
if (newFiles.length === 0) return;
|
||||||
@@ -69,6 +71,11 @@ export default function ImportScreen() {
|
|||||||
if (isImporting.current) return;
|
if (isImporting.current) return;
|
||||||
const path = await getSetting(db, 'auto_import_path');
|
const path = await getSetting(db, 'auto_import_path');
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
|
const instanceUrl = await getSetting(db, 'instance_url');
|
||||||
|
if (!instanceUrl) {
|
||||||
|
setState({ status: 'error', message: 'No Bincio instance configured. Go to Settings and enter an instance URL first — it\'s needed to download the extraction engine.' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setState({ status: 'loading', msg: 'Scanning…', current: 0, total: 0 });
|
setState({ status: 'loading', msg: 'Scanning…', current: 0, total: 0 });
|
||||||
const newFiles = await discoverNewFiles(db, path);
|
const newFiles = await discoverNewFiles(db, path);
|
||||||
|
|||||||
@@ -165,6 +165,12 @@ export default function SettingsScreen() {
|
|||||||
|
|
||||||
{Platform.OS === 'android' && (
|
{Platform.OS === 'android' && (
|
||||||
<Section title="Auto-import (Android)">
|
<Section title="Auto-import (Android)">
|
||||||
|
{!storedUrl ? (
|
||||||
|
<Text style={[styles.hint, styles.hintWarn]}>
|
||||||
|
Configure and save a Bincio instance URL above first — it's needed to download the extraction engine.
|
||||||
|
</Text>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<Field
|
<Field
|
||||||
label="Watch directory"
|
label="Watch directory"
|
||||||
placeholder="/sdcard/FitFiles"
|
placeholder="/sdcard/FitFiles"
|
||||||
@@ -174,9 +180,11 @@ export default function SettingsScreen() {
|
|||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
/>
|
/>
|
||||||
<Text style={styles.hint}>
|
<Text style={styles.hint}>
|
||||||
New FIT files in this directory are imported automatically when you
|
New FIT files in this folder are imported automatically when you
|
||||||
open the app. Leave blank to disable. Requires storage permission.
|
open the app. Leave blank to disable. Requires storage permission.
|
||||||
</Text>
|
</Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Section>
|
</Section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -326,6 +334,7 @@ const styles = StyleSheet.create({
|
|||||||
fieldLabel: { color: '#71717a', fontSize: 11, marginBottom: 4 },
|
fieldLabel: { color: '#71717a', fontSize: 11, marginBottom: 4 },
|
||||||
input: { color: '#f4f4f5', fontSize: 15 },
|
input: { color: '#f4f4f5', fontSize: 15 },
|
||||||
hint: { color: '#52525b', fontSize: 12, lineHeight: 16, padding: 12 },
|
hint: { color: '#52525b', fontSize: 12, lineHeight: 16, padding: 12 },
|
||||||
|
hintWarn: { color: '#a16207' },
|
||||||
row: {
|
row: {
|
||||||
flexDirection: 'row', justifyContent: 'space-between',
|
flexDirection: 'row', justifyContent: 'space-between',
|
||||||
paddingHorizontal: 14, paddingVertical: 12,
|
paddingHorizontal: 14, paddingVertical: 12,
|
||||||
|
|||||||
Reference in New Issue
Block a user