Refactor dialog stuff

This commit is contained in:
Henry Hiles 2026-04-04 18:26:19 -04:00
commit a8383951ba
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
6 changed files with 83 additions and 90 deletions

View file

@ -0,0 +1,27 @@
import "package:collection/collection.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/key_controller.dart";
import "package:nexus/controllers/spaces_controller.dart";
extension FocusRoom on WidgetRef {
Future<void> focusRoom(String id) async {
final spaces = watch(SpacesController.provider);
final space = spaces.firstWhereOrNull((space) => space.id == id);
await watch(KeyController.provider(KeyController.spaceKey).notifier).set(
space?.id ??
spaces
.firstWhere(
(space) =>
space.children.any((child) => child.metadata?.id == id),
)
.id,
);
if (space == null) {
await watch(
KeyController.provider(KeyController.roomKey).notifier,
).set(id);
}
}
}