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,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,