working jumps from notif page

Doesn't work from notif page pushed from notif controller
This commit is contained in:
Henry Hiles 2026-09-26 19:13:30 -04:00
commit c90a1c41b0
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
6 changed files with 136 additions and 57 deletions

View file

@ -1,3 +1,4 @@
import "package:flutter_hooks/flutter_hooks.dart";
import "package:material_ui/material_ui.dart";
import "package:hooks_riverpod/hooks_riverpod.dart";
import "package:nexus/controllers/init_complete.dart";
@ -7,45 +8,63 @@ import "package:nexus/widgets/sidebar.dart";
import "package:nexus/widgets/room_chat/room_chat.dart";
import "package:nexus/widgets/loading.dart";
class const ChatPage({super.key}) extends ConsumerWidget {
class const ChatPage({super.key}) extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) => LayoutBuilder(
builder: (context, constraints) {
final isDesktop = constraints.maxWidth > 650;
final showMembersByDefault = constraints.maxWidth > 1000;
final initComplete = ref.watch(InitCompleteController.provider);
final roomId = ref
.watch(KeyController.provider(KeyController.roomKey))
.requireValue;
Widget build(BuildContext context, WidgetRef ref) {
final initialHighlightedEvent = useState<String?>(null);
return SafeArea(
child: Scaffold(
appBar: initComplete ? null : Appbar(),
body: initComplete
? Row(
children: [
if (isDesktop) Sidebar(isDesktop: isDesktop),
Expanded(
child: RoomChat(
key: ValueKey(roomId),
roomId: roomId,
isDesktop: isDesktop,
showMembersByDefault: showMembersByDefault,
return LayoutBuilder(
builder: (context, constraints) {
final isDesktop = constraints.maxWidth > 650;
final showMembersByDefault = constraints.maxWidth > 1000;
final initComplete = ref.watch(InitCompleteController.provider);
final roomId = ref
.watch(KeyController.provider(KeyController.roomKey))
.requireValue;
return SafeArea(
child: Scaffold(
appBar: initComplete ? null : Appbar(),
body: initComplete
? Row(
children: [
if (isDesktop)
Sidebar(
isDesktop: isDesktop,
jumpToEvent: (eventId) =>
initialHighlightedEvent.value = eventId,
),
Expanded(
child: RoomChat(
key: ValueKey((
roomId,
initialHighlightedEvent.value,
)),
roomId: roomId,
isDesktop: isDesktop,
showMembersByDefault: showMembersByDefault,
initialHighlightedEvent:
initialHighlightedEvent.value,
),
),
],
)
: Center(
child: Column(
mainAxisSize: .min,
children: [Loading(), Text("Syncing...")],
),
],
)
: Center(
child: Column(
mainAxisSize: .min,
children: [Loading(), Text("Syncing...")],
),
),
drawer: isDesktop || !initComplete
? null
: Sidebar(isDesktop: isDesktop),
),
);
},
);
drawer: isDesktop || !initComplete
? null
: Sidebar(
isDesktop: isDesktop,
jumpToEvent: (eventId) =>
initialHighlightedEvent.value = eventId,
),
),
);
},
);
}
}

View file

@ -1,10 +1,13 @@
import "dart:async";
import "package:collection/collection.dart";
import "package:m3e_buttons/m3e_buttons.dart";
import "package:material_ui/material_ui.dart";
import "package:flutter_hooks/flutter_hooks.dart";
import "package:hooks_riverpod/hooks_riverpod.dart";
import "package:nexus/controllers/key.dart";
import "package:nexus/controllers/notifications.dart";
import "package:nexus/controllers/spaces.dart";
import "package:nexus/models/event.dart";
import "package:nexus/widgets/appbar.dart";
import "package:nexus/widgets/error_dialog.dart";
@ -16,6 +19,7 @@ import "package:super_sliver_list/super_sliver_list.dart";
class const NotificationsPage({
final String? highlightedEventId,
final bool defaultToAllNotifications = false,
required final void Function(String eventId) jumpToEvent,
super.key,
}) extends HookConsumerWidget {
@override
@ -127,9 +131,48 @@ class const NotificationsPage({
child: HighlightWrapper(
InkWell(
onTap: () {
// TODO: Jump to event
final spaces = ref.read(
SpacesController.provider,
);
final space = spaces.firstWhereOrNull(
(space) =>
space.children.any(
(room) =>
room.metadata?.id ==
event.roomId,
) ||
space.subSpaces.any(
(subSpace) =>
subSpace.children.any(
(room) =>
room.metadata?.id ==
event.roomId,
),
),
);
if (space == null) return;
ref
.read(
KeyController.provider(
KeyController.spaceKey,
).notifier,
)
.set(space.id);
ref
.read(
KeyController.provider(
KeyController.roomKey,
).notifier,
)
.set(event.roomId);
jumpToEvent(event.eventId);
Navigator.of(context).pop();
},
child: EventRenderer(event),
child: IgnorePointer(
child: EventRenderer(event),
),
),
isHighlighted: isHighlighted,
),