From a24a02deaf854dd916f81bb0ca5d37c1e8104402 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Fri, 16 Feb 2024 12:33:05 +0100 Subject: fix(circles): sort fallback if not member of circle Signed-off-by: skjnldsv --- src/components/AppNavigation/RootNavigation.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/AppNavigation/RootNavigation.vue b/src/components/AppNavigation/RootNavigation.vue index 24fc14b8..1dabe82f 100644 --- a/src/components/AppNavigation/RootNavigation.vue +++ b/src/components/AppNavigation/RootNavigation.vue @@ -349,9 +349,22 @@ export default { circlesMenu() { const menu = this.circles || [] menu.sort((a, b) => { + // If user is member of a and b, sort by level if (a?.initiator?.level !== b?.initiator?.level && a?.initiator?.level && b?.initiator?.level) { return b.initiator.level - a.initiator.level } + + // If user is member of a and not b, sort a first + if (a.initiator && !b.initiator) { + return -1 + } + + // If user is member of b and not a, sort b first + if (!a.initiator && b.initiator) { + return 1 + } + + // Else we sort by name return naturalCompare(a.toString(), b.toString(), { caseInsensitive: true }) }) -- cgit v1.2.3