From cba13aa6c723f36b1bb309e8a65b5d2298313bd6 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Thu, 26 Nov 2026 10:53:00 -0500 Subject: [PATCH] fixup room selected fallbacks --- lib/controllers/selected_room.dart | 11 +++++++++-- lib/widgets/sidebar/spaces_rail.dart | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/controllers/selected_room.dart b/lib/controllers/selected_room.dart index 075fcdd..a48a340 100644 --- a/lib/controllers/selected_room.dart +++ b/lib/controllers/selected_room.dart @@ -22,9 +22,16 @@ class SelectedRoomController extends Notifier { .addAll([?space.room?.metadata?.id]), ), ); - if (roomIds == null) return roomId; + if (roomIds == null || roomIds.contains(roomId)) return roomId; - return roomIds.contains(roomId) ? roomId : roomIds.firstOrNull; + final fallback = roomIds.firstOrNull; + Future.microtask(() { + if (!ref.mounted) return; + ref + .read(KeyController.provider(KeyController.roomKey).notifier) + .set(fallback); + }); + return fallback; } static final provider = NotifierProvider( diff --git a/lib/widgets/sidebar/spaces_rail.dart b/lib/widgets/sidebar/spaces_rail.dart index d84a40a..5dda4a4 100644 --- a/lib/widgets/sidebar/spaces_rail.dart +++ b/lib/widgets/sidebar/spaces_rail.dart @@ -44,7 +44,7 @@ class const SpacesRail({super.key}) extends ConsumerWidget { .set(spaces[value].id); ref .read(KeyController.provider(KeyController.roomKey).notifier) - .set(spaces[value].children.firstOrNull?.metadata?.id); + .set(spaces[value].allChildRooms.firstOrNull?.metadata?.id); }, sections: [ .new(