add error handling to continuousExport toggle functions

This commit is contained in:
Abhinav 2023-03-22 17:59:10 +05:30
parent 8f14580bb5
commit 4866651913
2 changed files with 38 additions and 26 deletions

View file

@ -84,14 +84,15 @@ export default function ExportModal(props: Props) {
}, []);
useEffect(() => {
if (!isElectron()) {
return;
}
try {
if (continuousExport) {
exportService.enableContinuousExport(startExport);
} else {
exportService.disableContinuousExport();
}
} catch (e) {
logError(e, 'error handling continuousExport change');
}
}, [continuousExport]);
useEffect(() => {

View file

@ -77,6 +77,7 @@ class ExportService {
}
enableContinuousExport(startExport: () => void) {
try {
if (this.continuousExportEventListener) {
return;
}
@ -93,9 +94,14 @@ class ExportService {
Events.LOCAL_FILES_UPDATED,
this.continuousExportEventListener
);
} catch (e) {
logError(e, 'failed to enableContinuousExport ');
throw e;
}
}
disableContinuousExport() {
try {
if (!this.continuousExportEventListener) {
return;
}
@ -103,6 +109,11 @@ class ExportService {
Events.LOCAL_FILES_UPDATED,
this.continuousExportEventListener
);
this.continuousExportEventListener = null;
} catch (e) {
logError(e, 'failed to disableContinuousExport');
throw e;
}
}
stopRunningExport() {