From 5cbce97ff9c2214e6acb47f0bccb0c9ac852a8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 22 Feb 2019 10:07:20 +0100 Subject: [PATCH] MOBILE-1979 sync: Fix activity syncing --- src/addon/mod/choice/providers/sync.ts | 4 +++- src/addon/mod/data/providers/sync.ts | 4 +++- src/addon/mod/feedback/providers/sync.ts | 4 +++- src/addon/mod/forum/providers/sync.ts | 4 +++- src/addon/mod/glossary/providers/sync.ts | 4 +++- src/addon/mod/lesson/providers/lesson-sync.ts | 4 +++- src/addon/mod/quiz/providers/quiz-sync.ts | 4 +++- src/addon/mod/scorm/providers/scorm-sync.ts | 4 +++- src/addon/mod/survey/providers/sync.ts | 4 +++- 9 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/addon/mod/choice/providers/sync.ts b/src/addon/mod/choice/providers/sync.ts index b260f1ba7..be612049a 100644 --- a/src/addon/mod/choice/providers/sync.ts +++ b/src/addon/mod/choice/providers/sync.ts @@ -140,7 +140,9 @@ export class AddonModChoiceSyncProvider extends CoreSyncBaseProvider { }; // Sync offline logs. - const syncPromise = this.logHelper.syncIfNeeded(AddonModChoiceProvider.COMPONENT, choiceId, siteId).finally(() => { + const syncPromise = this.logHelper.syncIfNeeded(AddonModChoiceProvider.COMPONENT, choiceId, siteId).catch(() => { + // Ignore errors. + }).then(() => { return this.choiceOffline.getResponse(choiceId, siteId, userId).catch(() => { // No offline data found, return empty object. return {}; diff --git a/src/addon/mod/data/providers/sync.ts b/src/addon/mod/data/providers/sync.ts index 22485fa93..7cf764845 100644 --- a/src/addon/mod/data/providers/sync.ts +++ b/src/addon/mod/data/providers/sync.ts @@ -151,7 +151,9 @@ export class AddonModDataSyncProvider extends CoreSyncBaseProvider { }; // Sync offline logs. - const syncPromise = this.logHelper.syncIfNeeded(AddonModDataProvider.COMPONENT, dataId, siteId).finally(() => { + const syncPromise = this.logHelper.syncIfNeeded(AddonModDataProvider.COMPONENT, dataId, siteId).catch(() => { + // Ignore errors. + }).then(() => { // Get answers to be sent. return this.dataOffline.getDatabaseEntries(dataId, siteId).catch(() => { // No offline data found, return empty object. diff --git a/src/addon/mod/feedback/providers/sync.ts b/src/addon/mod/feedback/providers/sync.ts index e9154d724..0a9364b48 100644 --- a/src/addon/mod/feedback/providers/sync.ts +++ b/src/addon/mod/feedback/providers/sync.ts @@ -147,7 +147,9 @@ export class AddonModFeedbackSyncProvider extends CoreSyncBaseProvider { this.logger.debug(`Try to sync feedback '${feedbackId}' in site ${siteId}'`); // Sync offline logs. - const syncPromise = this.logHelper.syncIfNeeded(AddonModFeedbackProvider.COMPONENT, feedbackId, siteId).finally(() => { + const syncPromise = this.logHelper.syncIfNeeded(AddonModFeedbackProvider.COMPONENT, feedbackId, siteId).catch(() => { + // Ignore errors. + }).then(() => { // Get offline responses to be sent. return this.feedbackOffline.getFeedbackResponses(feedbackId, siteId).catch(() => { // No offline data found, return empty array. diff --git a/src/addon/mod/forum/providers/sync.ts b/src/addon/mod/forum/providers/sync.ts index ddb33ab61..b6fc0559a 100644 --- a/src/addon/mod/forum/providers/sync.ts +++ b/src/addon/mod/forum/providers/sync.ts @@ -192,7 +192,9 @@ export class AddonModForumSyncProvider extends CoreSyncBaseProvider { }; // Sync offline logs. - const syncPromise = this.logHelper.syncIfNeeded(AddonModForumProvider.COMPONENT, forumId, siteId).finally(() => { + const syncPromise = this.logHelper.syncIfNeeded(AddonModForumProvider.COMPONENT, forumId, siteId).catch(() => { + // Ignore errors. + }).then(() => { // Get offline responses to be sent. return this.forumOffline.getNewDiscussions(forumId, siteId, userId).catch(() => { // No offline data found, return empty object. diff --git a/src/addon/mod/glossary/providers/sync.ts b/src/addon/mod/glossary/providers/sync.ts index af76e67d8..571745698 100644 --- a/src/addon/mod/glossary/providers/sync.ts +++ b/src/addon/mod/glossary/providers/sync.ts @@ -163,7 +163,9 @@ export class AddonModGlossarySyncProvider extends CoreSyncBaseProvider { }; // Sync offline logs. - const syncPromise = this.logHelper.syncIfNeeded(AddonModGlossaryProvider.COMPONENT, glossaryId, siteId).finally(() => { + const syncPromise = this.logHelper.syncIfNeeded(AddonModGlossaryProvider.COMPONENT, glossaryId, siteId).catch(() => { + // Ignore errors. + }).then(() => { // Get offline responses to be sent. return this.glossaryOffline.getGlossaryNewEntries(glossaryId, siteId, userId).catch(() => { // No offline data found, return empty object. diff --git a/src/addon/mod/lesson/providers/lesson-sync.ts b/src/addon/mod/lesson/providers/lesson-sync.ts index 7e34a3e76..68b741f94 100644 --- a/src/addon/mod/lesson/providers/lesson-sync.ts +++ b/src/addon/mod/lesson/providers/lesson-sync.ts @@ -272,7 +272,9 @@ export class AddonModLessonSyncProvider extends CoreSyncBaseProvider { this.logger.debug('Try to sync lesson ' + lessonId + ' in site ' + siteId); // Sync offline logs. - syncPromise = this.logHelper.syncIfNeeded(AddonModLessonProvider.COMPONENT, lessonId, siteId).finally(() => { + syncPromise = this.logHelper.syncIfNeeded(AddonModLessonProvider.COMPONENT, lessonId, siteId).catch(() => { + // Ignore errors. + }).then(() => { // Try to synchronize the attempts first. return this.lessonOfflineProvider.getLessonAttempts(lessonId, siteId); }).then((attempts) => { diff --git a/src/addon/mod/quiz/providers/quiz-sync.ts b/src/addon/mod/quiz/providers/quiz-sync.ts index a7ebbdbec..f70b29109 100644 --- a/src/addon/mod/quiz/providers/quiz-sync.ts +++ b/src/addon/mod/quiz/providers/quiz-sync.ts @@ -261,7 +261,9 @@ export class AddonModQuizSyncProvider extends CoreSyncBaseProvider { this.logger.debug('Try to sync quiz ' + quiz.id + ' in site ' + siteId); // Sync offline logs. - syncPromise = this.logHelper.syncIfNeeded(AddonModQuizProvider.COMPONENT, quiz.id, siteId).finally(() => { + syncPromise = this.logHelper.syncIfNeeded(AddonModQuizProvider.COMPONENT, quiz.id, siteId).catch(() => { + // Ignore errors. + }).then(() => { // Get all the offline attempts for the quiz. return this.quizOfflineProvider.getQuizAttempts(quiz.id, siteId); }).then((attempts) => { diff --git a/src/addon/mod/scorm/providers/scorm-sync.ts b/src/addon/mod/scorm/providers/scorm-sync.ts index 1bf3ea4cb..861dce5dc 100644 --- a/src/addon/mod/scorm/providers/scorm-sync.ts +++ b/src/addon/mod/scorm/providers/scorm-sync.ts @@ -649,7 +649,9 @@ export class AddonModScormSyncProvider extends CoreSyncBaseProvider { this.logger.debug('Try to sync SCORM ' + scorm.id + ' in site ' + siteId); // Sync offline logs. - syncPromise = this.logHelper.syncIfNeeded(AddonModScormProvider.COMPONENT, scorm.id, siteId).finally(() => { + syncPromise = this.logHelper.syncIfNeeded(AddonModScormProvider.COMPONENT, scorm.id, siteId).catch(() => { + // Ignore errors. + }).then(() => { // Get attempts data. We ignore cache for online attempts, so this call will fail if offline or server down. return this.scormProvider.getAttemptCount(scorm.id, false, true, siteId); }).then((attemptsData) => { diff --git a/src/addon/mod/survey/providers/sync.ts b/src/addon/mod/survey/providers/sync.ts index 580c24da4..2e301f5fa 100644 --- a/src/addon/mod/survey/providers/sync.ts +++ b/src/addon/mod/survey/providers/sync.ts @@ -143,7 +143,9 @@ export class AddonModSurveySyncProvider extends CoreSyncBaseProvider { }; // Sync offline logs. - const syncPromise = this.logHelper.syncIfNeeded(AddonModSurveyProvider.COMPONENT, surveyId, siteId).finally(() => { + const syncPromise = this.logHelper.syncIfNeeded(AddonModSurveyProvider.COMPONENT, surveyId, siteId).catch(() => { + // Ignore errors. + }).then(() => { // Get answers to be sent. return this.surveyOffline.getSurveyData(surveyId, siteId, userId).catch(() => { // No offline data found, return empty object.