diff --git a/src/addon/calendar/calendar.module.ts b/src/addon/calendar/calendar.module.ts index 06a8bbf6c..b0c7ecd7b 100644 --- a/src/addon/calendar/calendar.module.ts +++ b/src/addon/calendar/calendar.module.ts @@ -25,7 +25,6 @@ import { CoreCronDelegate } from '@providers/cron'; import { CoreInitDelegate } from '@providers/init'; import { CoreLocalNotificationsProvider } from '@providers/local-notifications'; import { CoreLoginHelperProvider } from '@core/login/providers/helper'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; import { CoreContentLinksDelegate } from '@core/contentlinks/providers/delegate'; import { AddonCalendarComponentsModule } from './components/components.module'; @@ -56,7 +55,7 @@ export const ADDON_CALENDAR_PROVIDERS: any[] = [ export class AddonCalendarModule { constructor(mainMenuDelegate: CoreMainMenuDelegate, calendarHandler: AddonCalendarMainMenuHandler, initDelegate: CoreInitDelegate, calendarProvider: AddonCalendarProvider, loginHelper: CoreLoginHelperProvider, - localNotificationsProvider: CoreLocalNotificationsProvider, updateManager: CoreUpdateManagerProvider, + localNotificationsProvider: CoreLocalNotificationsProvider, cronDelegate: CoreCronDelegate, syncHandler: AddonCalendarSyncCronHandler, contentLinksDelegate: CoreContentLinksDelegate, viewLinkHandler: AddonCalendarViewLinkHandler) { @@ -88,18 +87,5 @@ export class AddonCalendarModule { }); } }); - - // Allow migrating the table from the old app to the new schema. - // In the old app some calculated properties were stored when it shouldn't. Filter only the fields we want. - updateManager.registerSiteTableMigration({ - name: 'calendar_events', - newName: AddonCalendarProvider.EVENTS_TABLE, - filterFields: ['id', 'name', 'description', 'format', 'eventtype', 'courseid', 'timestart', 'timeduration', - 'categoryid', 'groupid', 'userid', 'instance', 'modulename', 'timemodified', 'repeatid', 'visible', 'uuid', - 'sequence', 'subscriptionid'] - }); - - // Migrate the component name. - updateManager.registerLocalNotifComponentMigration('mmaCalendarComponent', AddonCalendarProvider.COMPONENT); } } diff --git a/src/addon/messages/messages.module.ts b/src/addon/messages/messages.module.ts index a4bdffa38..69b1b0860 100644 --- a/src/addon/messages/messages.module.ts +++ b/src/addon/messages/messages.module.ts @@ -38,7 +38,6 @@ import { CoreSettingsDelegate } from '@core/settings/providers/delegate'; import { AddonMessagesSettingsHandler } from './providers/settings-handler'; import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate'; import { CoreUtilsProvider } from '@providers/utils/utils'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MESSAGES_PROVIDERS: any[] = [ @@ -75,7 +74,7 @@ export class AddonMessagesModule { userDelegate: CoreUserDelegate, cronDelegate: CoreCronDelegate, syncHandler: AddonMessagesSyncCronHandler, network: Network, zone: NgZone, messagesSync: AddonMessagesSyncProvider, appProvider: CoreAppProvider, localNotifications: CoreLocalNotificationsProvider, messagesProvider: AddonMessagesProvider, - sitesProvider: CoreSitesProvider, linkHelper: CoreContentLinksHelperProvider, updateManager: CoreUpdateManagerProvider, + sitesProvider: CoreSitesProvider, linkHelper: CoreContentLinksHelperProvider, settingsHandler: AddonMessagesSettingsHandler, settingsDelegate: CoreSettingsDelegate, pushNotificationsDelegate: CorePushNotificationsDelegate, utils: CoreUtilsProvider, addContactHandler: AddonMessagesAddContactUserHandler, blockContactHandler: AddonMessagesBlockContactUserHandler, @@ -136,21 +135,5 @@ export class AddonMessagesModule { // Listen for clicks in simulated push notifications. localNotifications.registerClick(AddonMessagesProvider.PUSH_SIMULATION_COMPONENT, notificationClicked); } - - // Allow migrating the table from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mma_messages_offline_messages', - newName: AddonMessagesOfflineProvider.MESSAGES_TABLE, - fields: [ - { - name: 'textformat', - delete: true - } - ] - }); - - // Migrate the component name. - updateManager.registerLocalNotifComponentMigration('mmaMessagesPushSimulation', - AddonMessagesProvider.PUSH_SIMULATION_COMPONENT); } } diff --git a/src/addon/mod/assign/assign.module.ts b/src/addon/mod/assign/assign.module.ts index 7a6edbfd6..fcea1f157 100644 --- a/src/addon/mod/assign/assign.module.ts +++ b/src/addon/mod/assign/assign.module.ts @@ -34,7 +34,6 @@ import { AddonModAssignListLinkHandler } from './providers/list-link-handler'; import { AddonModAssignPushClickHandler } from './providers/push-click-handler'; import { AddonModAssignSubmissionModule } from './submission/submission.module'; import { AddonModAssignFeedbackModule } from './feedback/feedback.module'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_ASSIGN_PROVIDERS: any[] = [ @@ -73,7 +72,7 @@ export const ADDON_MOD_ASSIGN_PROVIDERS: any[] = [ export class AddonModAssignModule { constructor(moduleDelegate: CoreCourseModuleDelegate, moduleHandler: AddonModAssignModuleHandler, prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModAssignPrefetchHandler, - cronDelegate: CoreCronDelegate, syncHandler: AddonModAssignSyncCronHandler, updateManager: CoreUpdateManagerProvider, + cronDelegate: CoreCronDelegate, syncHandler: AddonModAssignSyncCronHandler, contentLinksDelegate: CoreContentLinksDelegate, linkHandler: AddonModAssignIndexLinkHandler, listLinkHandler: AddonModAssignListLinkHandler, pushNotificationsDelegate: CorePushNotificationsDelegate, pushClickHandler: AddonModAssignPushClickHandler) { @@ -84,57 +83,5 @@ export class AddonModAssignModule { contentLinksDelegate.registerHandler(linkHandler); contentLinksDelegate.registerHandler(listLinkHandler); pushNotificationsDelegate.registerClickHandler(pushClickHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTablesMigration([ - { - name: 'mma_mod_assign_submissions', - newName: AddonModAssignOfflineProvider.SUBMISSIONS_TABLE, - fields: [ - { - name: 'assignmentid', - newName: 'assignid' - }, - { - name: 'submitted', - type: 'boolean' - }, - { - name: 'submissionstatement', - type: 'boolean' - }, - { - name: 'plugindata', - type: 'object' - } - ] - }, - { - name: 'mma_mod_assign_submissions_grading', - newName: AddonModAssignOfflineProvider.SUBMISSIONS_GRADES_TABLE, - fields: [ - { - name: 'assignmentid', - newName: 'assignid' - }, - { - name: 'addattempt', - type: 'boolean' - }, - { - name: 'applytoall', - type: 'boolean' - }, - { - name: 'outcomes', - type: 'object' - }, - { - name: 'plugindata', - type: 'object' - } - ] - } - ]); } } diff --git a/src/addon/mod/choice/choice.module.ts b/src/addon/mod/choice/choice.module.ts index ec5b9dc85..5e00daa85 100644 --- a/src/addon/mod/choice/choice.module.ts +++ b/src/addon/mod/choice/choice.module.ts @@ -26,7 +26,6 @@ import { AddonModChoicePrefetchHandler } from './providers/prefetch-handler'; import { AddonModChoiceSyncProvider } from './providers/sync'; import { AddonModChoiceSyncCronHandler } from './providers/sync-cron-handler'; import { AddonModChoiceOfflineProvider } from './providers/offline'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_CHOICE_PROVIDERS: any[] = [ @@ -56,7 +55,7 @@ export class AddonModChoiceModule { constructor(moduleDelegate: CoreCourseModuleDelegate, moduleHandler: AddonModChoiceModuleHandler, prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModChoicePrefetchHandler, contentLinksDelegate: CoreContentLinksDelegate, linkHandler: AddonModChoiceLinkHandler, - cronDelegate: CoreCronDelegate, syncHandler: AddonModChoiceSyncCronHandler, updateManager: CoreUpdateManagerProvider, + cronDelegate: CoreCronDelegate, syncHandler: AddonModChoiceSyncCronHandler, listLinkHandler: AddonModChoiceListLinkHandler) { moduleDelegate.registerHandler(moduleHandler); @@ -64,21 +63,5 @@ export class AddonModChoiceModule { contentLinksDelegate.registerHandler(linkHandler); contentLinksDelegate.registerHandler(listLinkHandler); cronDelegate.register(syncHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mma_mod_choice_offline_responses', - newName: AddonModChoiceOfflineProvider.CHOICE_TABLE, - fields: [ - { - name: 'responses', - type: 'object' - }, - { - name: 'deleting', - type: 'boolean' - } - ] - }); } } diff --git a/src/addon/mod/data/data.module.ts b/src/addon/mod/data/data.module.ts index 3f4a8d963..f3b8c0f7b 100644 --- a/src/addon/mod/data/data.module.ts +++ b/src/addon/mod/data/data.module.ts @@ -36,7 +36,6 @@ import { AddonModDataDefaultFieldHandler } from './providers/default-field-handl import { CoreTagAreaDelegate } from '@core/tag/providers/area-delegate'; import { AddonModDataTagAreaHandler } from './providers/tag-area-handler'; import { AddonModDataFieldModule } from './fields/field.module'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_DATA_PROVIDERS: any[] = [ @@ -77,7 +76,7 @@ export class AddonModDataModule { constructor(moduleDelegate: CoreCourseModuleDelegate, moduleHandler: AddonModDataModuleHandler, prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModDataPrefetchHandler, contentLinksDelegate: CoreContentLinksDelegate, linkHandler: AddonModDataLinkHandler, - cronDelegate: CoreCronDelegate, syncHandler: AddonModDataSyncCronHandler, updateManager: CoreUpdateManagerProvider, + cronDelegate: CoreCronDelegate, syncHandler: AddonModDataSyncCronHandler, approveLinkHandler: AddonModDataApproveLinkHandler, deleteLinkHandler: AddonModDataDeleteLinkHandler, showLinkHandler: AddonModDataShowLinkHandler, editLinkHandler: AddonModDataEditLinkHandler, listLinkHandler: AddonModDataListLinkHandler, tagAreaDelegate: CoreTagAreaDelegate, @@ -93,21 +92,5 @@ export class AddonModDataModule { contentLinksDelegate.registerHandler(listLinkHandler); cronDelegate.register(syncHandler); tagAreaDelegate.registerHandler(tagAreaHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mma_mod_data_entry', - newName: AddonModDataOfflineProvider.DATA_ENTRY_TABLE, - fields: [ - { - name: 'fields', - type: 'object' - }, - { - name: 'dataAndEntry', - delete: true - } - ] - }); } } diff --git a/src/addon/mod/feedback/feedback.module.ts b/src/addon/mod/feedback/feedback.module.ts index 8478d9254..d816ab94a 100644 --- a/src/addon/mod/feedback/feedback.module.ts +++ b/src/addon/mod/feedback/feedback.module.ts @@ -34,7 +34,6 @@ import { AddonModFeedbackPushClickHandler } from './providers/push-click-handler import { AddonModFeedbackSyncProvider } from './providers/sync'; import { AddonModFeedbackSyncCronHandler } from './providers/sync-cron-handler'; import { AddonModFeedbackOfflineProvider } from './providers/offline'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_FEEDBACK_PROVIDERS: any[] = [ @@ -73,7 +72,7 @@ export class AddonModFeedbackModule { prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModFeedbackPrefetchHandler, contentLinksDelegate: CoreContentLinksDelegate, linkHandler: AddonModFeedbackLinkHandler, cronDelegate: CoreCronDelegate, syncHandler: AddonModFeedbackSyncCronHandler, - analysisLinkHandler: AddonModFeedbackAnalysisLinkHandler, updateManager: CoreUpdateManagerProvider, + analysisLinkHandler: AddonModFeedbackAnalysisLinkHandler, showEntriesLinkHandler: AddonModFeedbackShowEntriesLinkHandler, showNonRespondentsLinkHandler: AddonModFeedbackShowNonRespondentsLinkHandler, completeLinkHandler: AddonModFeedbackCompleteLinkHandler, @@ -91,17 +90,5 @@ export class AddonModFeedbackModule { contentLinksDelegate.registerHandler(listLinkHandler); cronDelegate.register(syncHandler); pushNotificationsDelegate.registerClickHandler(pushClickHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mma_mod_feedback_responses', - newName: AddonModFeedbackOfflineProvider.FEEDBACK_TABLE, - fields: [ - { - name: 'responses', - type: 'object' - } - ] - }); } } diff --git a/src/addon/mod/forum/forum.module.ts b/src/addon/mod/forum/forum.module.ts index f38bd9d5f..a41da53ae 100644 --- a/src/addon/mod/forum/forum.module.ts +++ b/src/addon/mod/forum/forum.module.ts @@ -33,7 +33,6 @@ import { AddonModForumPostLinkHandler } from './providers/post-link-handler'; import { AddonModForumPushClickHandler } from './providers/push-click-handler'; import { AddonModForumTagAreaHandler } from './providers/tag-area-handler'; import { AddonModForumComponentsModule } from './components/components.module'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_FORUM_PROVIDERS: any[] = [ @@ -70,7 +69,7 @@ export class AddonModForumModule { prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModForumPrefetchHandler, cronDelegate: CoreCronDelegate, syncHandler: AddonModForumSyncCronHandler, linksDelegate: CoreContentLinksDelegate, indexHandler: AddonModForumIndexLinkHandler, discussionHandler: AddonModForumDiscussionLinkHandler, - updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModForumListLinkHandler, + listLinkHandler: AddonModForumListLinkHandler, pushNotificationsDelegate: CorePushNotificationsDelegate, pushClickHandler: AddonModForumPushClickHandler, postLinkHandler: AddonModForumPostLinkHandler, tagAreaDelegate: CoreTagAreaDelegate, tagAreaHandler: AddonModForumTagAreaHandler) { @@ -84,41 +83,5 @@ export class AddonModForumModule { linksDelegate.registerHandler(postLinkHandler); pushNotificationsDelegate.registerClickHandler(pushClickHandler); tagAreaDelegate.registerHandler(tagAreaHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTablesMigration([ - { - name: 'mma_mod_forum_offline_discussions', - newName: AddonModForumOfflineProvider.DISCUSSIONS_TABLE, - fields: [ - { - name: 'forumAndUser', - delete: true - }, - { - name: 'options', - type: 'object' - } - ] - }, - { - name: 'mma_mod_forum_offline_replies', - newName: AddonModForumOfflineProvider.REPLIES_TABLE, - fields: [ - { - name: 'forumAndUser', - delete: true - }, - { - name: 'discussionAndUser', - delete: true - }, - { - name: 'options', - type: 'object' - } - ] - } - ]); } } diff --git a/src/addon/mod/glossary/glossary.module.ts b/src/addon/mod/glossary/glossary.module.ts index e1ad371ea..06ba0a136 100644 --- a/src/addon/mod/glossary/glossary.module.ts +++ b/src/addon/mod/glossary/glossary.module.ts @@ -31,7 +31,6 @@ import { AddonModGlossaryListLinkHandler } from './providers/list-link-handler'; import { AddonModGlossaryEditLinkHandler } from './providers/edit-link-handler'; import { AddonModGlossaryTagAreaHandler } from './providers/tag-area-handler'; import { AddonModGlossaryComponentsModule } from './components/components.module'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_GLOSSARY_PROVIDERS: any[] = [ @@ -67,7 +66,7 @@ export class AddonModGlossaryModule { prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModGlossaryPrefetchHandler, cronDelegate: CoreCronDelegate, syncHandler: AddonModGlossarySyncCronHandler, linksDelegate: CoreContentLinksDelegate, indexHandler: AddonModGlossaryIndexLinkHandler, discussionHandler: AddonModGlossaryEntryLinkHandler, - updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModGlossaryListLinkHandler, + listLinkHandler: AddonModGlossaryListLinkHandler, editLinkHandler: AddonModGlossaryEditLinkHandler, tagAreaDelegate: CoreTagAreaDelegate, tagAreaHandler: AddonModGlossaryTagAreaHandler) { @@ -79,29 +78,5 @@ export class AddonModGlossaryModule { linksDelegate.registerHandler(listLinkHandler); linksDelegate.registerHandler(editLinkHandler); tagAreaDelegate.registerHandler(tagAreaHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mma_mod_glossary_add_entry', - newName: AddonModGlossaryOfflineProvider.ENTRIES_TABLE, - fields: [ - { - name: 'glossaryAndConcept', - delete: true - }, - { - name: 'glossaryAndUser', - delete: true - }, - { - name: 'options', - type: 'object' - }, - { - name: 'attachments', - type: 'object' - } - ] - }); } } diff --git a/src/addon/mod/lesson/lesson.module.ts b/src/addon/mod/lesson/lesson.module.ts index 8fcce6995..29d874b01 100644 --- a/src/addon/mod/lesson/lesson.module.ts +++ b/src/addon/mod/lesson/lesson.module.ts @@ -31,7 +31,6 @@ import { AddonModLessonGradeLinkHandler } from './providers/grade-link-handler'; import { AddonModLessonReportLinkHandler } from './providers/report-link-handler'; import { AddonModLessonListLinkHandler } from './providers/list-link-handler'; import { AddonModLessonPushClickHandler } from './providers/push-click-handler'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_LESSON_PROVIDERS: any[] = [ @@ -67,7 +66,7 @@ export class AddonModLessonModule { prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModLessonPrefetchHandler, cronDelegate: CoreCronDelegate, syncHandler: AddonModLessonSyncCronHandler, linksDelegate: CoreContentLinksDelegate, indexHandler: AddonModLessonIndexLinkHandler, gradeHandler: AddonModLessonGradeLinkHandler, - reportHandler: AddonModLessonReportLinkHandler, updateManager: CoreUpdateManagerProvider, + reportHandler: AddonModLessonReportLinkHandler, listLinkHandler: AddonModLessonListLinkHandler, pushNotificationsDelegate: CorePushNotificationsDelegate, pushClickHandler: AddonModLessonPushClickHandler) { @@ -79,71 +78,5 @@ export class AddonModLessonModule { linksDelegate.registerHandler(reportHandler); linksDelegate.registerHandler(listLinkHandler); pushNotificationsDelegate.registerClickHandler(pushClickHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTablesMigration([ - { - name: 'mma_mod_lesson_password', - newName: AddonModLessonProvider.PASSWORD_TABLE, - fields: [ - { - name: 'id', - newName: 'lessonid' - } - ] - }, - { - name: 'mma_mod_lesson_retakes', - newName: AddonModLessonOfflineProvider.RETAKES_TABLE, - fields: [ - { - name: 'finished', - type: 'boolean' - }, - { - name: 'outoftime', - type: 'boolean' - } - ] - }, - { - name: 'mma_mod_lesson_page_attempts', - newName: AddonModLessonOfflineProvider.PAGE_ATTEMPTS_TABLE, - fields: [ - { - name: 'lessonAndPage', - delete: true - }, - { - name: 'lessonAndRetake', - delete: true - }, - { - name: 'lessonAndRetakeAndType', - delete: true - }, - { - name: 'lessonAndRetakeAndPage', - delete: true - }, - { - name: 'data', - type: 'object' - }, - { - name: 'correct', - type: 'boolean' - }, - { - name: 'userAnswer', - type: 'object' - } - ] - }, - { - name: 'mma_mod_lesson_retakes_finished_sync', - newName: AddonModLessonSyncProvider.RETAKES_FINISHED_TABLE - } - ]); } } diff --git a/src/addon/mod/quiz/accessrules/password/password.module.ts b/src/addon/mod/quiz/accessrules/password/password.module.ts index 8063d7685..941af9fed 100644 --- a/src/addon/mod/quiz/accessrules/password/password.module.ts +++ b/src/addon/mod/quiz/accessrules/password/password.module.ts @@ -20,7 +20,6 @@ import { CoreComponentsModule } from '@components/components.module'; import { AddonModQuizAccessPasswordHandler } from './providers/handler'; import { AddonModQuizAccessPasswordComponent } from './component/password'; import { AddonModQuizAccessRuleDelegate } from '../../providers/access-rules-delegate'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; @NgModule({ declarations: [ @@ -43,14 +42,7 @@ import { CoreUpdateManagerProvider } from '@providers/update-manager'; ] }) export class AddonModQuizAccessPasswordModule { - constructor(accessRuleDelegate: AddonModQuizAccessRuleDelegate, handler: AddonModQuizAccessPasswordHandler, - updateManager: CoreUpdateManagerProvider) { + constructor(accessRuleDelegate: AddonModQuizAccessRuleDelegate, handler: AddonModQuizAccessPasswordHandler) { accessRuleDelegate.registerHandler(handler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mod_quiz_access_password', - newName: AddonModQuizAccessPasswordHandler.PASSWORD_TABLE - }); } } diff --git a/src/addon/mod/quiz/quiz.module.ts b/src/addon/mod/quiz/quiz.module.ts index e77749f5f..62e92519f 100644 --- a/src/addon/mod/quiz/quiz.module.ts +++ b/src/addon/mod/quiz/quiz.module.ts @@ -32,7 +32,6 @@ import { AddonModQuizReviewLinkHandler } from './providers/review-link-handler'; import { AddonModQuizListLinkHandler } from './providers/list-link-handler'; import { AddonModQuizPushClickHandler } from './providers/push-click-handler'; import { AddonModQuizComponentsModule } from './components/components.module'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // Access rules. import { AddonModQuizAccessDelayBetweenAttemptsModule } from './accessrules/delaybetweenattempts/delaybetweenattempts.module'; @@ -90,7 +89,7 @@ export class AddonModQuizModule { prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModQuizPrefetchHandler, cronDelegate: CoreCronDelegate, syncHandler: AddonModQuizSyncCronHandler, linksDelegate: CoreContentLinksDelegate, indexHandler: AddonModQuizIndexLinkHandler, gradeHandler: AddonModQuizGradeLinkHandler, - reviewHandler: AddonModQuizReviewLinkHandler, updateManager: CoreUpdateManagerProvider, + reviewHandler: AddonModQuizReviewLinkHandler, listLinkHandler: AddonModQuizListLinkHandler, pushNotificationsDelegate: CorePushNotificationsDelegate, pushClickHandler: AddonModQuizPushClickHandler) { @@ -102,21 +101,5 @@ export class AddonModQuizModule { linksDelegate.registerHandler(reviewHandler); linksDelegate.registerHandler(listLinkHandler); pushNotificationsDelegate.registerClickHandler(pushClickHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mod_quiz_attempts', - newName: AddonModQuizOfflineProvider.ATTEMPTS_TABLE, - fields: [ - { - name: 'quizAndUser', - delete: true - }, - { - name: 'finished', - type: 'boolean' - } - ] - }); } } diff --git a/src/addon/mod/scorm/scorm.module.ts b/src/addon/mod/scorm/scorm.module.ts index 7542353a7..8676d3769 100644 --- a/src/addon/mod/scorm/scorm.module.ts +++ b/src/addon/mod/scorm/scorm.module.ts @@ -28,7 +28,6 @@ import { AddonModScormGradeLinkHandler } from './providers/grade-link-handler'; import { AddonModScormListLinkHandler } from './providers/list-link-handler'; import { AddonModScormSyncProvider } from './providers/scorm-sync'; import { AddonModScormComponentsModule } from './components/components.module'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_SCORM_PROVIDERS: any[] = [ @@ -62,7 +61,7 @@ export class AddonModScormModule { prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModScormPrefetchHandler, cronDelegate: CoreCronDelegate, syncHandler: AddonModScormSyncCronHandler, linksDelegate: CoreContentLinksDelegate, indexHandler: AddonModScormIndexLinkHandler, gradeHandler: AddonModScormGradeLinkHandler, - updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModScormListLinkHandler) { + listLinkHandler: AddonModScormListLinkHandler) { moduleDelegate.registerHandler(moduleHandler); prefetchDelegate.registerHandler(prefetchHandler); @@ -70,41 +69,5 @@ export class AddonModScormModule { linksDelegate.registerHandler(indexHandler); linksDelegate.registerHandler(gradeHandler); linksDelegate.registerHandler(listLinkHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTablesMigration([ - { - name: 'mod_scorm_offline_attempts', - newName: AddonModScormOfflineProvider.ATTEMPTS_TABLE, - fields: [ - { - name: 'snapshot', - type: 'object' - }, - { - name: 'scormAndUser', - delete: true - } - ] - }, - { - name: 'mod_scorm_offline_scos_tracks', - newName: AddonModScormOfflineProvider.TRACKS_TABLE, - fields: [ - { - name: 'value', - type: 'object' - }, - { - name: 'scormUserAttempt', - delete: true - }, - { - name: 'scormUserAttemptSynced', - delete: true - } - ] - } - ]); } } diff --git a/src/addon/mod/survey/survey.module.ts b/src/addon/mod/survey/survey.module.ts index f57b47080..53829079e 100644 --- a/src/addon/mod/survey/survey.module.ts +++ b/src/addon/mod/survey/survey.module.ts @@ -27,7 +27,6 @@ import { AddonModSurveyPrefetchHandler } from './providers/prefetch-handler'; import { AddonModSurveySyncProvider } from './providers/sync'; import { AddonModSurveySyncCronHandler } from './providers/sync-cron-handler'; import { AddonModSurveyOfflineProvider } from './providers/offline'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_SURVEY_PROVIDERS: any[] = [ @@ -59,7 +58,7 @@ export class AddonModSurveyModule { constructor(moduleDelegate: CoreCourseModuleDelegate, moduleHandler: AddonModSurveyModuleHandler, prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModSurveyPrefetchHandler, contentLinksDelegate: CoreContentLinksDelegate, linkHandler: AddonModSurveyLinkHandler, - cronDelegate: CoreCronDelegate, syncHandler: AddonModSurveySyncCronHandler, updateManager: CoreUpdateManagerProvider, + cronDelegate: CoreCronDelegate, syncHandler: AddonModSurveySyncCronHandler, listLinkHandler: AddonModSurveyListLinkHandler) { moduleDelegate.registerHandler(moduleHandler); @@ -67,17 +66,5 @@ export class AddonModSurveyModule { contentLinksDelegate.registerHandler(linkHandler); contentLinksDelegate.registerHandler(listLinkHandler); cronDelegate.register(syncHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mma_mod_survey_answers', - newName: AddonModSurveyOfflineProvider.SURVEY_TABLE, - fields: [ - { - name: 'answers', - type: 'object' - } - ] - }); } } diff --git a/src/addon/mod/wiki/wiki.module.ts b/src/addon/mod/wiki/wiki.module.ts index 9d2c85269..f8e576209 100644 --- a/src/addon/mod/wiki/wiki.module.ts +++ b/src/addon/mod/wiki/wiki.module.ts @@ -31,7 +31,6 @@ import { AddonModWikiCreateLinkHandler } from './providers/create-link-handler'; import { AddonModWikiEditLinkHandler } from './providers/edit-link-handler'; import { AddonModWikiListLinkHandler } from './providers/list-link-handler'; import { AddonModWikiTagAreaHandler } from './providers/tag-area-handler'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_WIKI_PROVIDERS: any[] = [ @@ -67,7 +66,7 @@ export class AddonModWikiModule { cronDelegate: CoreCronDelegate, syncHandler: AddonModWikiSyncCronHandler, linksDelegate: CoreContentLinksDelegate, indexHandler: AddonModWikiIndexLinkHandler, pageOrMapHandler: AddonModWikiPageOrMapLinkHandler, createHandler: AddonModWikiCreateLinkHandler, editHandler: AddonModWikiEditLinkHandler, - updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModWikiListLinkHandler, + listLinkHandler: AddonModWikiListLinkHandler, tagAreaDelegate: CoreTagAreaDelegate, tagAreaHandler: AddonModWikiTagAreaHandler) { moduleDelegate.registerHandler(moduleHandler); @@ -79,21 +78,5 @@ export class AddonModWikiModule { linksDelegate.registerHandler(editHandler); linksDelegate.registerHandler(listLinkHandler); tagAreaDelegate.registerHandler(tagAreaHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mma_mod_wiki_new_pages_store', - newName: AddonModWikiOfflineProvider.NEW_PAGES_TABLE, - fields: [ - { - name: 'subwikiWikiUserGroup', - delete: true - }, - { - name: 'caneditpage', - type: 'boolean' - } - ] - }); } } diff --git a/src/addon/mod/workshop/workshop.module.ts b/src/addon/mod/workshop/workshop.module.ts index 4d7d6779a..77e4052bf 100644 --- a/src/addon/mod/workshop/workshop.module.ts +++ b/src/addon/mod/workshop/workshop.module.ts @@ -29,7 +29,6 @@ import { AddonModWorkshopHelperProvider } from './providers/helper'; import { AddonWorkshopAssessmentStrategyDelegate } from './providers/assessment-strategy-delegate'; import { AddonModWorkshopPrefetchHandler } from './providers/prefetch-handler'; import { AddonModWorkshopSyncCronHandler } from './providers/sync-cron-handler'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_MOD_WORKSHOP_PROVIDERS: any[] = [ @@ -65,60 +64,12 @@ export class AddonModWorkshopModule { contentLinksDelegate: CoreContentLinksDelegate, linkHandler: AddonModWorkshopLinkHandler, prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModWorkshopPrefetchHandler, cronDelegate: CoreCronDelegate, syncHandler: AddonModWorkshopSyncCronHandler, - updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModWorkshopListLinkHandler) { + listLinkHandler: AddonModWorkshopListLinkHandler) { moduleDelegate.registerHandler(moduleHandler); contentLinksDelegate.registerHandler(linkHandler); contentLinksDelegate.registerHandler(listLinkHandler); prefetchDelegate.registerHandler(prefetchHandler); cronDelegate.register(syncHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTablesMigration([ - { - name: 'mma_mod_workshop_offline_submissions', - newName: AddonModWorkshopOfflineProvider.SUBMISSIONS_TABLE, - fields: [ - { - name: 'attachmentsid', - type: 'object' - } - ] - }, - { - name: 'mma_mod_workshop_offline_assessments', - newName: AddonModWorkshopOfflineProvider.ASSESSMENTS_TABLE, - fields: [ - { - name: 'inputdata', - type: 'object' - } - ] - }, - { - name: 'mma_mod_workshop_offline_evaluate_submissions', - newName: AddonModWorkshopOfflineProvider.EVALUATE_SUBMISSIONS_TABLE, - fields: [ - { - name: 'gradeover', - type: 'object' - }, - { - name: 'published', - type: 'boolean' - } - ] - }, - { - name: 'mma_mod_workshop_offline_evaluate_assessments', - newName: AddonModWorkshopOfflineProvider.EVALUATE_ASSESSMENTS_TABLE, - fields: [ - { - name: 'gradinggradeover', - type: 'object' - } - ] - } - ]); } } diff --git a/src/addon/notes/notes.module.ts b/src/addon/notes/notes.module.ts index 40b418b7d..0d803fa2a 100644 --- a/src/addon/notes/notes.module.ts +++ b/src/addon/notes/notes.module.ts @@ -23,7 +23,6 @@ import { AddonNotesComponentsModule } from './components/components.module'; import { CoreCourseOptionsDelegate } from '@core/course/providers/options-delegate'; import { CoreCronDelegate } from '@providers/cron'; import { CoreUserDelegate } from '@core/user/providers/user-delegate'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const ADDON_NOTES_PROVIDERS: any[] = [ @@ -49,17 +48,11 @@ export const ADDON_NOTES_PROVIDERS: any[] = [ export class AddonNotesModule { constructor(courseOptionsDelegate: CoreCourseOptionsDelegate, courseOptionHandler: AddonNotesCourseOptionHandler, userDelegate: CoreUserDelegate, userHandler: AddonNotesUserHandler, - cronDelegate: CoreCronDelegate, syncHandler: AddonNotesSyncCronHandler, updateManager: CoreUpdateManagerProvider) { + cronDelegate: CoreCronDelegate, syncHandler: AddonNotesSyncCronHandler) { // Register handlers. courseOptionsDelegate.registerHandler(courseOptionHandler); userDelegate.registerHandler(userHandler); cronDelegate.register(syncHandler); - - // Allow migrating the tables from the old app to the new schema. - updateManager.registerSiteTableMigration({ - name: 'mma_notes_offline_notes', - newName: AddonNotesOfflineProvider.NOTES_TABLE - }); } } diff --git a/src/core/pushnotifications/pushnotifications.module.ts b/src/core/pushnotifications/pushnotifications.module.ts index 12496465d..34ce8b119 100644 --- a/src/core/pushnotifications/pushnotifications.module.ts +++ b/src/core/pushnotifications/pushnotifications.module.ts @@ -22,7 +22,6 @@ import { CoreCronDelegate } from '@providers/cron'; import { CoreEventsProvider } from '@providers/events'; import { CoreLoggerProvider } from '@providers/logger'; import { CoreLocalNotificationsProvider } from '@providers/local-notifications'; -import { CoreUpdateManagerProvider } from '@providers/update-manager'; // List of providers (without handlers). export const CORE_PUSHNOTIFICATIONS_PROVIDERS: any[] = [ @@ -45,7 +44,7 @@ export const CORE_PUSHNOTIFICATIONS_PROVIDERS: any[] = [ export class CorePushNotificationsModule { constructor(platform: Platform, pushNotificationsProvider: CorePushNotificationsProvider, eventsProvider: CoreEventsProvider, localNotificationsProvider: CoreLocalNotificationsProvider, loggerProvider: CoreLoggerProvider, - updateManager: CoreUpdateManagerProvider, cronDelegate: CoreCronDelegate, + cronDelegate: CoreCronDelegate, registerCronHandler: CorePushNotificationsRegisterCronHandler, unregisterCronHandler: CorePushNotificationsUnregisterCronHandler) { @@ -92,20 +91,5 @@ export class CorePushNotificationsModule { // Log notification dismissed event. pushNotificationsProvider.logEvent('moodle_notification_dismiss', notification, true); }); - - // Allow migrating the table from the old app to the new schema. - updateManager.registerAppTableMigration({ - name: 'mma_pushnotifications_badge', - newName: CorePushNotificationsProvider.BADGE_TABLE, - fields: [ - { - name: 'siteid', - newName: 'siteId' - } - ] - }); - - // Migrate the component name. - updateManager.registerLocalNotifComponentMigration('mmaPushNotifications', CorePushNotificationsProvider.COMPONENT); } } diff --git a/src/providers/filepool.ts b/src/providers/filepool.ts index 8c51e421f..11e53f420 100644 --- a/src/providers/filepool.ts +++ b/src/providers/filepool.ts @@ -1346,28 +1346,6 @@ export class CoreFilepoolProvider { }); } - /** - * Fill Missing Extension In Files, used to migrate from previous file handling. - * Reserved for core use, please do not call. - * - * @param siteId SiteID to get migrated - * @return Promise resolved when done. - */ - fillMissingExtensionInFiles(siteId: string): Promise { - this.logger.debug('Fill missing extensions in files of ' + siteId); - - return this.sitesProvider.getSiteDb(siteId).then((db) => { - return db.getAllRecords(this.FILES_TABLE).then((entries) => { - const promises = []; - entries.forEach((entry) => { - promises.push(this.fillExtensionInFile(entry, siteId)); - }); - - return Promise.all(promises); - }); - }); - } - /** * Fix a component ID to always be a Number if possible. * @@ -3018,33 +2996,6 @@ export class CoreFilepoolProvider { }); } - /** - * Remove extension from fileId in queue, used to migrate from previous file handling. - * - * @return Promise resolved when done. - */ - async treatExtensionInQueue(): Promise { - await this.dbReady; - - this.logger.debug('Treat extensions in queue'); - - const entries = await this.appDB.getAllRecords(this.QUEUE_TABLE); - - return Promise.all(entries.map((entry) => { - - // For files in the queue, we only need to remove the extension from the fileId. - // After downloading, additional info will be added. - const fileId = entry.fileId; - entry.fileId = this.mimeUtils.removeExtension(fileId); - - if (fileId == entry.fileId) { - return; - } - - return this.appDB.updateRecords(this.QUEUE_TABLE, { fileId: entry.fileId }, { fileId: fileId }); - })); - } - /** * Resolves or rejects a queue deferred and removes it from the list. * diff --git a/src/providers/update-manager.ts b/src/providers/update-manager.ts index 5aec55467..b32ef3499 100644 --- a/src/providers/update-manager.ts +++ b/src/providers/update-manager.ts @@ -14,45 +14,9 @@ import { Injectable } from '@angular/core'; import { CoreConfigProvider } from './config'; -import { CoreFilepoolProvider } from './filepool'; import { CoreInitHandler, CoreInitDelegate } from './init'; -import { CoreLocalNotificationsProvider } from './local-notifications'; import { CoreLoggerProvider } from './logger'; -import { CoreSitesProvider } from './sites'; -import { CoreUtilsProvider } from './utils/utils'; -import { CoreTimeUtilsProvider } from './utils/time'; import { CoreConfigConstants } from '../configconstants'; -import { AddonCalendarProvider } from '@addon/calendar/providers/calendar'; - -/** - * Data to migrate a store of Ionic 1 app to the SQLite DB. - */ -export interface CoreUpdateManagerMigrateTable { - /** - * Current name of the store/table. - */ - name: string; - - /** - * New name of the table. If not defined, "name" will be used. - */ - newName?: string; - - /** - * An object to rename and convert some fields of the table/store. - */ - fields?: { - name: string, // Field name in the old app. - newName?: string, // New field name. If not provided, keep the same name. - type?: string, // Type of the field if it needs to be treated: 'any', 'object', 'date', 'boolean'. - delete?: boolean // Whether the field must be deleted because it isn't needed in the new schema. - }[]; - - /** - * If set, all the fields that aren't in this array will be deleted. The names in this list should be the new names. - */ - filterFields?: string[]; -} /** * Factory to handle app updates. This factory shouldn't be used outside of core. @@ -68,253 +32,8 @@ export class CoreUpdateManagerProvider implements CoreInitHandler { protected VERSION_APPLIED = 'version_applied'; protected logger; - protected localNotificationsComponentsMigrate: {[old: string]: string} = {}; - /** - * Tables to migrate from app DB ('MoodleMobile'). Include all the core ones to decrease the dependencies. - */ - protected appDBTables: CoreUpdateManagerMigrateTable[] = [ - { - name: 'config', - newName: 'core_config', - fields: [ - { - name: 'value', - type: 'any' - } - ] - }, - { - name: 'cron' - }, - { - name: 'current_site', - fields: [ - { - name: 'siteid', - newName: 'siteId' - } - ] - }, - { - name: 'desktop_local_notifications', - fields: [ - { - name: 'data', - type: 'object' - }, - { - name: 'triggered', - type: 'boolean' - } - ], - filterFields: ['id', 'title', 'text', 'at', 'data', 'triggered'] - }, - { - name: 'files_queue', - newName: 'filepool_files_queue', - fields: [ - { - name: 'isexternalfile', - type: 'boolean' - }, - { - name: 'links', - type: 'object' - }, - { - name: 'sortorder', - delete: true - } - ] - }, - { - name: 'notification_components' - }, - { - name: 'notification_sites' - }, - { - name: 'notifications_triggered' - }, - { - name: 'shared_files' - }, - { - name: 'sites', - fields: [ - { - name: 'siteurl', - newName: 'siteUrl' - }, - { - name: 'infos', - newName: 'info', - type: 'object' - }, - { - name: 'privatetoken', - newName: 'privateToken' - }, - { - name: 'config', - type: 'object' - }, - { - name: 'loggedout', - newName: 'loggedOut' - } - ] - }, - ]; - - /** - * Tables to migrate from each site DB. Include all the core ones to decrease the dependencies. - */ - protected siteDBTables: CoreUpdateManagerMigrateTable[] = [ - { - name: 'check_updates_times', - fields: [ - { - name: 'courseid', - newName: 'courseId' - } - ] - }, - { - name: 'course_status', - fields: [ - { - name: 'previous', - newName: 'previousStatus' - }, - { - name: 'downloadtime', - newName: 'downloadTime' - }, - { - name: 'previousdownloadtime', - newName: 'previousDownloadTime' - } - ] - }, - { - name: 'filepool', - newName: 'filepool_files', - fields: [ - { - name: 'stale', - type: 'boolean' - }, - { - name: 'downloaded', - newName: 'downloadTime' - }, - { - name: 'isexternalfile', - type: 'boolean' - } - ] - }, - { - name: 'files_links', - newName: 'filepool_files_links', - fields: [ - { - name: 'componentAndId', - delete: true - } - ] - }, - { - name: 'filepool_packages', - fields: [ - { - name: 'downloadtime', - newName: 'downloadTime' - }, - { - name: 'previousdownloadtime', - newName: 'previousDownloadTime' - }, - { - name: 'revision', // Move the value of 'revision' to 'extra' so SCORMs keep working. - newName: 'extra' - }, - { - name: 'timemodified', - delete: true - } - ] - }, - { - name: 'mm_emulator_last_received_notification', - newName: 'core_emulator_last_received_notification', - filterFields: ['component', 'id', 'timecreated'] - }, - { - name: 'questions', - fields: [ - { - name: 'componentId', - newName: 'componentid' - }, - { - name: 'componentAndAttempt', - delete: true - }, - { - name: 'componentAndComponentId', - delete: true - } - ] - }, - { - name: 'question_answers', - fields: [ - { - name: 'componentId', - newName: 'componentid' - }, - { - name: 'componentAndAttempt', - delete: true - }, - { - name: 'componentAndComponentId', - delete: true - }, - { - name: 'componentAndAttemptAndQuestion', - delete: true - } - ] - }, - { - name: 'sync' - }, - { - name: 'users' - }, - { - name: 'wscache', - fields: [ - { - name: 'data', - type: 'object' - }, - { - name: 'expirationtime', - newName: 'expirationTime' - } - ] - } - ]; - - constructor(logger: CoreLoggerProvider, private configProvider: CoreConfigProvider, private sitesProvider: CoreSitesProvider, - private filepoolProvider: CoreFilepoolProvider, private notifProvider: CoreLocalNotificationsProvider, - private utils: CoreUtilsProvider, private timeUtils: CoreTimeUtilsProvider, - private calendarProvider: AddonCalendarProvider) { + constructor(logger: CoreLoggerProvider, private configProvider: CoreConfigProvider) { this.logger = logger.getInstance('CoreUpdateManagerProvider'); } @@ -330,21 +49,7 @@ export class CoreUpdateManagerProvider implements CoreInitHandler { return this.configProvider.get(this.VERSION_APPLIED, 0).then((versionApplied: number) => { - if (versionCode >= 2013 && versionApplied < 2013 && versionApplied > 0) { - promises.push(this.migrateFileExtensions()); - } - - if (versionCode >= 2017 && versionApplied < 2017 && versionApplied > 0) { - promises.push(this.setCalendarDefaultNotifTime()); - promises.push(this.setSitesConfig()); - } - - // In version 2018 we adapted the forum offline stores to match a new schema. - // However, due to the migration of data to SQLite we can no longer do that. - - if (versionCode >= 3500 && versionApplied < 3500 && versionApplied > 0) { - promises.push(this.logoutLegacySites()); - } + // Put here the code to treat app updates. return Promise.all(promises).then(() => { return this.configProvider.set(this.VERSION_APPLIED, versionCode); @@ -353,193 +58,4 @@ export class CoreUpdateManagerProvider implements CoreInitHandler { }); }); } - - /** - * Register several app tables to be migrated to the new schema. - * - * @param tables The tables to migrate. - */ - registerAppTablesMigration(tables: CoreUpdateManagerMigrateTable[]): void { - tables.forEach((table) => { - this.registerAppTableMigration(table); - }); - } - - /** - * Register an app table to be migrated to the new schema. - * - * @param table The table to migrate. - */ - registerAppTableMigration(table: CoreUpdateManagerMigrateTable): void { - this.appDBTables.push(table); - } - - /** - * Register several site tables to be migrated to the new schema. - * - * @param tables The tables to migrate. - */ - registerSiteTablesMigration(tables: CoreUpdateManagerMigrateTable[]): void { - tables.forEach((table) => { - this.registerSiteTableMigration(table); - }); - } - - /** - * Register a site table to be migrated to the new schema. - * - * @param table The table to migrate. - */ - registerSiteTableMigration(table: CoreUpdateManagerMigrateTable): void { - this.siteDBTables.push(table); - } - - /** - * Register a migration of component name for local notifications. - * - * @param oldName The old name. - * @param newName The new name. - */ - registerLocalNotifComponentMigration(oldName: string, newName: string): void { - this.localNotificationsComponentsMigrate[oldName] = newName; - } - - /** - * Migrates files filling extensions. - * - * @return Promise resolved when the site migration is finished. - */ - protected migrateFileExtensions(): Promise { - return this.sitesProvider.getSitesIds().then((sites) => { - const promises = []; - sites.forEach((siteId) => { - promises.push(this.filepoolProvider.fillMissingExtensionInFiles(siteId)); - }); - promises.push(this.filepoolProvider.treatExtensionInQueue()); - - return Promise.all(promises); - }); - } - - /** - * Calendar default notification time is configurable from version 3.2.1, and a new option "Default" is added. - * All events that were configured to use the fixed default time should now be configured to use "Default" option. - * - * @return Promise resolved when the events are configured. - */ - protected setCalendarDefaultNotifTime(): Promise { - if (!this.notifProvider.isAvailable()) { - // Local notifications not available, nothing to do. - return Promise.resolve(); - } - - const now = this.timeUtils.timestamp(); - - return this.sitesProvider.getSitesIds().then((siteIds) => { - - const promises = []; - siteIds.forEach((siteId) => { - // Get stored events. - promises.push(this.calendarProvider.getAllEventsFromLocalDb(siteId).then((events) => { - const eventPromises = []; - - events.forEach((event) => { - if (event.notificationtime && event.notificationtime == AddonCalendarProvider.DEFAULT_NOTIFICATION_TIME) { - eventPromises.push(this.calendarProvider.addEventReminder(event, -1, siteId)); - } else if (event.notificationtime && event.notificationtime > 0) { - const time = event.timestart - event.notificationtime * 60; - - if (time < now) { - // Old reminder, just not add this. - return; - } - eventPromises.push(this.calendarProvider.addEventReminder(event, time, siteId)); - } - }); - - return Promise.all(eventPromises); - })); - }); - - return Promise.all(promises); - }); - } - - /** - * In version 3.2.1 we want the site config to be stored in each site if available. - * Since it can be slow, we'll only block retrieving the config of current site, the rest will be in background. - * - * @return Promise resolved when the config is loaded for the current site (if any). - */ - protected setSitesConfig(): Promise { - return this.sitesProvider.getSitesIds().then((siteIds) => { - - return this.sitesProvider.getStoredCurrentSiteId().catch(() => { - // Error getting current site. - }).then((currentSiteId) => { - let promise; - - // Load the config of current site first. - if (currentSiteId) { - promise = this.setSiteConfig(currentSiteId); - } else { - promise = Promise.resolve(); - } - - // Load the config of rest of sites in background. - siteIds.forEach((siteId) => { - if (siteId != currentSiteId) { - this.setSiteConfig(siteId); - } - }); - - return promise; - }); - }); - } - - /** - * Store the config of a site. - * - * @param siteId Site ID. - * @return Promise resolved when the config is loaded for the site. - */ - protected setSiteConfig(siteId: string): Promise { - return this.sitesProvider.getSite(siteId).then((site) => { - if (site.getStoredConfig() || !site.wsAvailable('tool_mobile_get_config')) { - // Site already has the config or it cannot be retrieved. Stop. - return; - } - - // Get the site config. - return site.getConfig().then((config) => { - return this.sitesProvider.addSite( - site.getId(), site.getURL(), site.getToken(), site.getInfo(), site.getPrivateToken(), config); - }).catch(() => { - // Ignore errors. - }); - }); - } - - /** - * Logout from legacy sites. - * - * @return Promise resolved when done. - */ - protected logoutLegacySites(): Promise { - return this.sitesProvider.getSitesIds().then((siteIds) => { - const promises = []; - - siteIds.forEach((siteId) => { - promises.push(this.sitesProvider.getSite(siteId).then((site) => { - // If the site is a legacy site, mark it as logged out so the user has to authenticate again. - if (this.sitesProvider.isLegacyMoodleByInfo(site.getInfo())) { - return this.sitesProvider.setSiteLoggedOut(site.getId(), true); - } - })); - }); - - return this.utils.allPromises(promises); - }); - } }