Skip to content

Commit

Permalink
#1269 | Stop sync if user declines reset
Browse files Browse the repository at this point in the history
  • Loading branch information
1t5j0y committed Mar 13, 2024
1 parent dba5e37 commit 62769aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
14 changes: 7 additions & 7 deletions packages/openchs-android/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/openchs-android/src/service/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class SyncService extends BaseService {
const userResponse = await userConfirmation();
if (userResponse === 'YES')
return this.getService(ResetSyncService).resetSync();
else
return Promise.reject(new IgnorableSyncError("userDeclinedResetSync", "User Declined Reset Sync"));
}
}

Expand Down
7 changes: 5 additions & 2 deletions packages/openchs-android/src/views/SyncComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import AsyncAlert from "./common/AsyncAlert";
import {ScheduleDummySyncJob, ScheduleSyncJob} from "../AvniBackgroundJob";
import AvniError from "../framework/errorHandling/AvniError";
import ErrorUtil from "../framework/errorHandling/ErrorUtil";
import {IgnorableSyncError} from "openchs-models";

class SyncComponent extends AbstractComponent {
unsubscribe;
Expand Down Expand Up @@ -54,14 +55,16 @@ class SyncComponent extends AbstractComponent {

_onError(error, ignoreBugsnag) {
General.logError(`${this.viewName()}-Sync`, error);
const isIgnorableSyncError = error instanceof IgnorableSyncError;
this.setState({syncStarted: false});
this.dispatchAction(SyncTelemetryActions.SYNC_FAILED);
!isIgnorableSyncError && this.dispatchAction(SyncTelemetryActions.SYNC_FAILED);
const isServerError = error instanceof ServerError;
//Do not notify bugsnag if it's a server error since it would have been notified on server bugsnag already.
if (!ignoreBugsnag && !isServerError) {
if (!ignoreBugsnag && !isServerError && !isIgnorableSyncError) {
ErrorUtil.notifyBugsnag(error, "SyncComponent");
}
this.dispatchAction(SyncActions.ON_ERROR);
if (isIgnorableSyncError) return;
if (error instanceof AuthenticationError && error.authErrCode !== 'NetworkingError') {
General.logError(this.viewName(), "Could not authenticate");
General.logError(this.viewName(), error);
Expand Down

0 comments on commit 62769aa

Please sign in to comment.