Add support for jumping to event links (#103)
Fixes #78. Reviewed-on: #103
This commit is contained in:
parent
597112f5d3
commit
1c4bf99be2
16 changed files with 169 additions and 113 deletions
|
|
@ -1,27 +1,28 @@
|
|||
import "package:collection/collection.dart";
|
||||
import "package:flutter_riverpod/experimental/mutation.dart";
|
||||
import "package:nexus/controllers/contextual_event.dart";
|
||||
import "package:nexus/controllers/key.dart";
|
||||
import "package:nexus/controllers/spaces.dart";
|
||||
import "package:nexus/models/space.dart";
|
||||
|
||||
extension FocusRoom on MutationTarget {
|
||||
Future<bool> focusRoom(String id) async {
|
||||
Future<bool> focusRoom(String roomId, [int? eventRowId]) async {
|
||||
final spaces = container.read(SpacesController.provider);
|
||||
|
||||
if (spaces.firstWhereOrNull((space) => space.id == id) case Space _?) {
|
||||
if (spaces.firstWhereOrNull((space) => space.id == roomId) case Space _?) {
|
||||
await container
|
||||
.read(KeyController.provider(KeyController.spaceKey).notifier)
|
||||
.set(id);
|
||||
.set(roomId);
|
||||
return true;
|
||||
}
|
||||
|
||||
final parent = spaces.firstWhereOrNull(
|
||||
(space) =>
|
||||
space.children.any((room) => room.metadata?.id == id) ||
|
||||
space.children.any((room) => room.metadata?.id == roomId) ||
|
||||
space.subSpaces.any(
|
||||
(sub) =>
|
||||
sub.room.metadata?.id == id ||
|
||||
sub.children.any((room) => room.metadata?.id == id),
|
||||
sub.room.metadata?.id == roomId ||
|
||||
sub.children.any((room) => room.metadata?.id == roomId),
|
||||
),
|
||||
);
|
||||
if (parent == null) return false;
|
||||
|
|
@ -32,7 +33,13 @@ extension FocusRoom on MutationTarget {
|
|||
|
||||
await container
|
||||
.read(KeyController.provider(KeyController.roomKey).notifier)
|
||||
.set(id);
|
||||
.set(roomId);
|
||||
|
||||
if (eventRowId != null) {
|
||||
container
|
||||
.read(ContextualEventController.provider(roomId).notifier)
|
||||
.set(eventRowId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue