From f63534109e2eba4aaf6a3813340f2f45a3f4cf5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 16 Mar 2021 12:37:25 +0100 Subject: [PATCH] MOBILE-3528 core: Fix handlers order if one hasn't priority --- src/core/classes/delegate-sorted.ts | 4 ++-- src/core/features/course/services/course-options-delegate.ts | 4 ++-- .../features/fileuploader/services/fileuploader-delegate.ts | 4 ++-- src/core/features/user/services/user-delegate.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/classes/delegate-sorted.ts b/src/core/classes/delegate-sorted.ts index 751573574..3c65e3b73 100644 --- a/src/core/classes/delegate-sorted.ts +++ b/src/core/classes/delegate-sorted.ts @@ -86,14 +86,14 @@ export class CoreSortedDelegate< const handler = this.enabledHandlers[name]; const data = handler.getDisplayData(); - data.priority = handler.priority; + data.priority = handler.priority || 0; data.name = handler.name; displayData.push(data); } // Sort them by priority. - displayData.sort((a, b) => (b.priority || 0) - (a.priority || 0)); + displayData.sort((a, b) => b.priority! - a.priority!); this.loaded = true; this.sortedHandlersRxJs.next(displayData); diff --git a/src/core/features/course/services/course-options-delegate.ts b/src/core/features/course/services/course-options-delegate.ts index 52fb9d3f8..dc54a21bb 100644 --- a/src/core/features/course/services/course-options-delegate.ts +++ b/src/core/features/course/services/course-options-delegate.ts @@ -450,7 +450,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate { handlersToDisplay.push({ data: data, - priority: handler.priority, + priority: handler.priority || 0, prefetch: handler.prefetch && handler.prefetch.bind(handler), name: handler.name, }); @@ -467,7 +467,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate (b.priority || 0) - (a.priority || 0)); + ) => b.priority! - a.priority!); return handlersToDisplay; } diff --git a/src/core/features/fileuploader/services/fileuploader-delegate.ts b/src/core/features/fileuploader/services/fileuploader-delegate.ts index 7dcc70d74..6bcb5146e 100644 --- a/src/core/features/fileuploader/services/fileuploader-delegate.ts +++ b/src/core/features/fileuploader/services/fileuploader-delegate.ts @@ -183,13 +183,13 @@ export class CoreFileUploaderDelegateService extends CoreDelegate (a.priority || 0) <= (b.priority || 0) ? 1 : -1); + handlers.sort((a, b) => a.priority! <= b.priority! ? 1 : -1); return handlers; } diff --git a/src/core/features/user/services/user-delegate.ts b/src/core/features/user/services/user-delegate.ts index 551e22ad9..38c11a9c3 100644 --- a/src/core/features/user/services/user-delegate.ts +++ b/src/core/features/user/services/user-delegate.ts @@ -311,7 +311,7 @@ export class CoreUserDelegateService extends CoreDelegate (b.priority || 0) - (a.priority || 0)); + userData.handlers.sort((a, b) => b.priority! - a.priority!); userData.loaded = true; userData.observable.next(userData.handlers); }