fix unread logic to take into account subspaces

This commit is contained in:
Henry Hiles 2026-06-06 21:19:01 -04:00
commit 309d0df581
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -100,17 +100,32 @@ class Sidebar extends HookConsumerWidget {
destinations: spaces destinations: spaces
.map( .map(
(space) => NavigationRailM3EDestination( (space) => NavigationRailM3EDestination(
badgeCount: switch (space.children.fold( badgeCount: switch (space.children
0, .addAll(
(previousValue, room) => space.subSpaces
previousValue + .map((element) => element.children)
(room.metadata?.unreadNotifications ?? 0), .flattened,
)) { )
.fold(
0,
(previousValue, room) =>
previousValue +
(room.metadata?.unreadNotifications ?? 0),
)) {
0 => 0 =>
space.children.any( space.children
(room) => .addAll(
room.metadata?.unreadMessages != 0, space.subSpaces
) .map(
(element) => element.children,
)
.flattened,
)
.any(
(room) =>
room.metadata?.unreadMessages !=
0,
)
? 0 ? 0
: null, : null,
int badgeCount => badgeCount, int badgeCount => badgeCount,