Skip to content

Commit

Permalink
fix(circles): sort fallback if not member of circle
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Feb 16, 2024
1 parent 1a8cd22 commit 05f04df
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/AppNavigation/RootNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 357 in src/components/AppNavigation/RootNavigation.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/RootNavigation.vue#L357

Added line #L357 was not covered by tests
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

Check warning on line 364 in src/components/AppNavigation/RootNavigation.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppNavigation/RootNavigation.vue#L364

Added line #L364 was not covered by tests
}

// Else we sort by name
return naturalCompare(a.toString(), b.toString(), { caseInsensitive: true })
})

Expand Down

0 comments on commit 05f04df

Please sign in to comment.