fixup room selected fallbacks

This commit is contained in:
Henry Hiles 2026-11-26 10:53:00 -05:00
commit cba13aa6c7
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 10 additions and 3 deletions

View file

@ -22,9 +22,16 @@ class SelectedRoomController extends Notifier<String?> {
.addAll([?space.room?.metadata?.id]), .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<SelectedRoomController, String?>( static final provider = NotifierProvider<SelectedRoomController, String?>(

View file

@ -44,7 +44,7 @@ class const SpacesRail({super.key}) extends ConsumerWidget {
.set(spaces[value].id); .set(spaces[value].id);
ref ref
.read(KeyController.provider(KeyController.roomKey).notifier) .read(KeyController.provider(KeyController.roomKey).notifier)
.set(spaces[value].children.firstOrNull?.metadata?.id); .set(spaces[value].allChildRooms.firstOrNull?.metadata?.id);
}, },
sections: [ sections: [
.new( .new(