MOBILE-3528 core: Fix handlers order if one hasn't priority

main
Pau Ferrer Ocaña 2021-03-16 12:37:25 +01:00
parent 8689ae76f6
commit f63534109e
4 changed files with 7 additions and 7 deletions

View File

@ -86,14 +86,14 @@ export class CoreSortedDelegate<
const handler = this.enabledHandlers[name];
const data = <DisplayType> 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);

View File

@ -450,7 +450,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
promises.push(Promise.resolve(getFunction!.call(handler, courseWithOptions)).then((data) => {
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<CoreCourseOpt
handlersToDisplay.sort((
a: CoreCourseOptionsHandlerToDisplay | CoreCourseOptionsMenuHandlerToDisplay,
b: CoreCourseOptionsHandlerToDisplay | CoreCourseOptionsMenuHandlerToDisplay,
) => (b.priority || 0) - (a.priority || 0));
) => b.priority! - a.priority!);
return handlersToDisplay;
}

View File

@ -183,13 +183,13 @@ export class CoreFileUploaderDelegateService extends CoreDelegate<CoreFileUpload
}
const data: CoreFileUploaderHandlerDataToReturn = handler.getData();
data.priority = handler.priority;
data.priority = handler.priority || 0;
data.mimetypes = supportedMimetypes;
handlers.push(data);
}
// Sort them by priority.
handlers.sort((a, b) => (a.priority || 0) <= (b.priority || 0) ? 1 : -1);
handlers.sort((a, b) => a.priority! <= b.priority! ? 1 : -1);
return handlers;
}

View File

@ -311,7 +311,7 @@ export class CoreUserDelegateService extends CoreDelegate<CoreUserProfileHandler
}));
// Sort them by priority.
userData.handlers.sort((a, b) => (b.priority || 0) - (a.priority || 0));
userData.handlers.sort((a, b) => b.priority! - a.priority!);
userData.loaded = true;
userData.observable.next(userData.handlers);
}