Skip to content

Commit

Permalink
refactor: use member.group_count for group filtering too
Browse files Browse the repository at this point in the history
  • Loading branch information
Draconizations committed Oct 4, 2024
1 parent b446f3f commit 66f2c4e
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/lib/dash/filters.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,37 +475,32 @@ function filterMembersByGroup<T>(
case FilterMode.HIGHERTHAN:
// include any member that is in MORE groups than...
list = list.filter((i) => {
if (
groupList.filter((g) => g.members?.includes((i as Member).uuid || "")).length >
(value as number)
)
return true
const count = (i as Member)?.group_count || 0
if (count > (value as number)) return true
return false
})
break
case FilterMode.LOWERTHAN:
// include any member that is in MORE groups than...
list = list.filter((i) => {
if (
groupList.filter((g) => g.members?.includes((i as Member).uuid || "")).length <
(value as number)
)
return true
return false
const count = (i as Member)?.group_count || 0
if (count < (value as number)) return false
})
break
case FilterMode.NOTEMPTY:
// include any member a group
list = list.filter((i) => {
if (groupList.some((g) => g.members?.includes((i as Member).uuid || ""))) return true
return false
const count = (i as Member)?.group_count || 0
if (count === 0) return false
return true
})
break
case FilterMode.EMPTY:
// include any member without a group
list = list.filter((i) => {
if (groupList.some((g) => g.members?.includes((i as Member).uuid || ""))) return false
return true
const count = (i as Member)?.group_count || 0
if (count === 0) return true
return false
})
break
}
Expand Down

0 comments on commit 66f2c4e

Please sign in to comment.