Merge pull request #1777 from crazyserver/MOBILE-1979-2

MOBILE-1979 sync: Fix activity syncing
main
Juan Leyva 2019-02-22 11:01:41 +01:00 committed by GitHub
commit 63d84eec23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 27 additions and 9 deletions

View File

@ -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 {};

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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.