Skip to content

Commit ce95207

Browse files
committed
Fixed possible loop on first recording directory selection after app install/update
1 parent 68c041e commit ce95207

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/app/services/recordings.service.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,22 @@ export class RecordingsService {
149149
await this.save();
150150

151151
}
152-
catch(error) {
153-
console.error(error);
154-
this.mbs.showError({
155-
appErrorCode: 'ERR_DB001',
156-
error
157-
});
158-
};
152+
catch(error: any) {
153+
if (error.code === ErrorCode.ERR_INVALID_URI) {
154+
this.selectRecordingsDirectory(() => this.refreshContent());
155+
}
156+
else {
157+
console.error(error);
158+
this.mbs.showError({
159+
appErrorCode: 'ERR_DB001',
160+
error
161+
});
162+
}
163+
}
164+
finally {
165+
this.refreshProgress.next(0);
166+
}
159167

160-
this.refreshProgress.next(0);
161168
}
162169

163170
/**
@@ -388,7 +395,17 @@ export class RecordingsService {
388395
directoryUri: this.settings.recordingsDirectoryUri,
389396
name: DB_FILENAME,
390397
};
391-
this.settings.dbFileUri = (await AndroidSAF.getFileUri(opt)).uri;
398+
try {
399+
this.settings.dbFileUri = (await AndroidSAF.getFileUri(opt)).uri;
400+
}
401+
catch (e: any) {
402+
if (e.code === ErrorCode.ERR_INVALID_URI) {
403+
this.settings.dbFileUri = undefined;
404+
}
405+
else {
406+
throw e;
407+
}
408+
}
392409
this.settings.save();
393410
}
394411

0 commit comments

Comments
 (0)