From 94b215816e352cb31e8a4139ef37816c5fba6e88 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 5 Oct 2020 11:42:21 +0200 Subject: [PATCH] MOBILE-3523 core: Fix handlers order if one hasn't priority --- src/core/contentlinks/providers/delegate.ts | 2 +- src/core/course/providers/options-delegate.ts | 2 +- src/core/fileuploader/providers/delegate.ts | 2 +- src/core/mainmenu/providers/delegate.ts | 2 +- src/core/pushnotifications/providers/delegate.ts | 1 + src/core/settings/providers/delegate.ts | 2 +- src/core/siteplugins/classes/handlers/course-option-handler.ts | 2 +- src/core/siteplugins/classes/handlers/main-menu-handler.ts | 2 +- src/core/siteplugins/classes/handlers/message-output-handler.ts | 2 +- src/core/siteplugins/classes/handlers/settings-handler.ts | 2 +- src/core/siteplugins/classes/handlers/user-handler.ts | 2 +- src/core/user/providers/user-delegate.ts | 2 +- 12 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/core/contentlinks/providers/delegate.ts b/src/core/contentlinks/providers/delegate.ts index b323f60be..eb9c526e1 100644 --- a/src/core/contentlinks/providers/delegate.ts +++ b/src/core/contentlinks/providers/delegate.ts @@ -191,7 +191,7 @@ export class CoreContentLinksDelegate { // Add them to the list. linkActions.push({ - priority: handler.priority, + priority: handler.priority || 0, actions: actions }); } diff --git a/src/core/course/providers/options-delegate.ts b/src/core/course/providers/options-delegate.ts index 815be116e..cf46e95de 100644 --- a/src/core/course/providers/options-delegate.ts +++ b/src/core/course/providers/options-delegate.ts @@ -405,7 +405,7 @@ export class CoreCourseOptionsDelegate extends CoreDelegate { promises.push(Promise.resolve(getFunction.call(handler, injector, course)).then((data) => { handlersToDisplay.push({ data: data, - priority: handler.priority, + priority: handler.priority || 0, prefetch: handler.prefetch && handler.prefetch.bind(handler), name: handler.name }); diff --git a/src/core/fileuploader/providers/delegate.ts b/src/core/fileuploader/providers/delegate.ts index a0de9d939..77b8be619 100644 --- a/src/core/fileuploader/providers/delegate.ts +++ b/src/core/fileuploader/providers/delegate.ts @@ -177,7 +177,7 @@ export class CoreFileUploaderDelegate extends CoreDelegate { } const data: CoreFileUploaderHandlerDataToReturn = handler.getData(); - data.priority = handler.priority; + data.priority = handler.priority || 0; data.mimetypes = supportedMimetypes; handlers.push(data); } diff --git a/src/core/mainmenu/providers/delegate.ts b/src/core/mainmenu/providers/delegate.ts index 9f07edc13..e044b6dd3 100644 --- a/src/core/mainmenu/providers/delegate.ts +++ b/src/core/mainmenu/providers/delegate.ts @@ -162,7 +162,7 @@ export class CoreMainMenuDelegate extends CoreDelegate { handlersData.push({ name: name, data: data, - priority: handler.priority + priority: handler.priority || 0, }); } diff --git a/src/core/pushnotifications/providers/delegate.ts b/src/core/pushnotifications/providers/delegate.ts index b8b10cbd7..94297132c 100644 --- a/src/core/pushnotifications/providers/delegate.ts +++ b/src/core/pushnotifications/providers/delegate.ts @@ -177,6 +177,7 @@ export class CorePushNotificationsDelegate { this.logger.log(`Registered addon '${handler.name}'`); this.clickHandlers[handler.name] = handler; + handler.priority = handler.priority || 0; return true; } diff --git a/src/core/settings/providers/delegate.ts b/src/core/settings/providers/delegate.ts index ea5557024..c6a892d0a 100644 --- a/src/core/settings/providers/delegate.ts +++ b/src/core/settings/providers/delegate.ts @@ -108,7 +108,7 @@ export class CoreSettingsDelegate extends CoreDelegate { handlersData.push({ data: data, - priority: handler.priority + priority: handler.priority || 0, }); } diff --git a/src/core/siteplugins/classes/handlers/course-option-handler.ts b/src/core/siteplugins/classes/handlers/course-option-handler.ts index e1a572172..90205d756 100644 --- a/src/core/siteplugins/classes/handlers/course-option-handler.ts +++ b/src/core/siteplugins/classes/handlers/course-option-handler.ts @@ -35,7 +35,7 @@ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandl protected utils: CoreUtilsProvider) { super(name); - this.priority = handlerSchema.priority; + this.priority = handlerSchema.priority || 0; this.isMenuHandler = !!handlerSchema.ismenuhandler; } diff --git a/src/core/siteplugins/classes/handlers/main-menu-handler.ts b/src/core/siteplugins/classes/handlers/main-menu-handler.ts index 5ff904abf..448c95672 100644 --- a/src/core/siteplugins/classes/handlers/main-menu-handler.ts +++ b/src/core/siteplugins/classes/handlers/main-menu-handler.ts @@ -25,7 +25,7 @@ export class CoreSitePluginsMainMenuHandler extends CoreSitePluginsBaseHandler i protected initResult: any) { super(name); - this.priority = handlerSchema.priority; + this.priority = handlerSchema.priority || 0; } /** diff --git a/src/core/siteplugins/classes/handlers/message-output-handler.ts b/src/core/siteplugins/classes/handlers/message-output-handler.ts index 1e0985ccc..569c1f3c5 100644 --- a/src/core/siteplugins/classes/handlers/message-output-handler.ts +++ b/src/core/siteplugins/classes/handlers/message-output-handler.ts @@ -32,7 +32,7 @@ export class CoreSitePluginsMessageOutputHandler extends CoreSitePluginsBaseHand */ getDisplayData(): AddonMessageOutputHandlerData { return { - priority: this.handlerSchema.priority, + priority: this.handlerSchema.priority || 0, label: this.title, icon: this.handlerSchema.displaydata.icon, page: 'CoreSitePluginsPluginPage', diff --git a/src/core/siteplugins/classes/handlers/settings-handler.ts b/src/core/siteplugins/classes/handlers/settings-handler.ts index 1267faa07..94c99c963 100644 --- a/src/core/siteplugins/classes/handlers/settings-handler.ts +++ b/src/core/siteplugins/classes/handlers/settings-handler.ts @@ -25,7 +25,7 @@ export class CoreSitePluginsSettingsHandler extends CoreSitePluginsBaseHandler i protected initResult: any) { super(name); - this.priority = handlerSchema.priority; + this.priority = handlerSchema.priority || 0; } /** diff --git a/src/core/siteplugins/classes/handlers/user-handler.ts b/src/core/siteplugins/classes/handlers/user-handler.ts index ae381c477..690c9fbc9 100644 --- a/src/core/siteplugins/classes/handlers/user-handler.ts +++ b/src/core/siteplugins/classes/handlers/user-handler.ts @@ -43,7 +43,7 @@ export class CoreSitePluginsUserProfileHandler extends CoreSitePluginsBaseHandle protected utils: CoreUtilsProvider) { super(name); - this.priority = handlerSchema.priority; + this.priority = handlerSchema.priority || 0; // Only support TYPE_COMMUNICATION and TYPE_NEW_PAGE. this.type = handlerSchema.type != CoreUserDelegate.TYPE_COMMUNICATION ? diff --git a/src/core/user/providers/user-delegate.ts b/src/core/user/providers/user-delegate.ts index 588bb817d..b78ed122d 100644 --- a/src/core/user/providers/user-delegate.ts +++ b/src/core/user/providers/user-delegate.ts @@ -260,7 +260,7 @@ export class CoreUserDelegate extends CoreDelegate { userData.handlers.push({ name: name, data: handler.getDisplayData(user, courseId), - priority: handler.priority, + priority: handler.priority || 0, type: handler.type || CoreUserDelegate.TYPE_NEW_PAGE }); }