fix unread logic to take into account subspaces
This commit is contained in:
parent
3310d9b907
commit
309d0df581
1 changed files with 25 additions and 10 deletions
|
|
@ -100,16 +100,31 @@ class Sidebar extends HookConsumerWidget {
|
|||
destinations: spaces
|
||||
.map(
|
||||
(space) => NavigationRailM3EDestination(
|
||||
badgeCount: switch (space.children.fold(
|
||||
badgeCount: switch (space.children
|
||||
.addAll(
|
||||
space.subSpaces
|
||||
.map((element) => element.children)
|
||||
.flattened,
|
||||
)
|
||||
.fold(
|
||||
0,
|
||||
(previousValue, room) =>
|
||||
previousValue +
|
||||
(room.metadata?.unreadNotifications ?? 0),
|
||||
)) {
|
||||
0 =>
|
||||
space.children.any(
|
||||
space.children
|
||||
.addAll(
|
||||
space.subSpaces
|
||||
.map(
|
||||
(element) => element.children,
|
||||
)
|
||||
.flattened,
|
||||
)
|
||||
.any(
|
||||
(room) =>
|
||||
room.metadata?.unreadMessages != 0,
|
||||
room.metadata?.unreadMessages !=
|
||||
0,
|
||||
)
|
||||
? 0
|
||||
: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue