Watch
1
0
Fork
You've already forked nexus
0
forked from Nexus/nexus

open notifications page on notif tap

please please please let me never touch c++ again i hate it

also the c++ got reformatted here but i dont really care
This commit is contained in:
Henry Hiles 2026-09-21 16:56:12 -04:00
commit 700b4e720f
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
5 changed files with 348 additions and 111 deletions

View file

@ -1,6 +1,7 @@
import "dart:async";
import "dart:io";
import "package:flutter/foundation.dart";
import "package:flutter/services.dart";
import "package:material_ui/material_ui.dart";
import "package:nexus/controllers/portal.dart";
import "package:nexus/main.dart";
@ -47,37 +48,28 @@ class NotificationController
}
if (Platform.isLinux) {
final portal = await ref.watch(PortalController.provider.future);
const notificationChannel = MethodChannel("nexus/notifications");
portal.notification.actionInvoked.listen((event) {
if (event.action != "app.event") {
notificationChannel.setMethodCallHandler((call) async {
if (call.method != "notificationClicked") {
return;
}
final eventId = call.arguments as String;
if (navigatorKey.currentContext case final context?) {
if (context.mounted) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => NotificationsPage(
highlightedEventId: event.id,
defaultToAllNotifications: true,
),
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => NotificationsPage(
highlightedEventId: eventId,
defaultToAllNotifications: true,
),
);
}
),
);
}
});
}
ref.onDispose(() {
// The portal client owns its D-Bus connection.
if (Platform.isLinux) {
ref.read(PortalController.provider.future).then((portal) {
portal.close();
});
}
});
return notifications;
}
@ -124,7 +116,7 @@ class NotificationController
debugPrint("Sending notification for $id");
if (Platform.isLinux) {
final portal = await ref.read(PortalController.provider.future);
final portal = await ref.watch(PortalController.provider.future);
await portal.notification.addNotification(
id.toString(),
@ -132,6 +124,7 @@ class NotificationController
body: body,
icon: icon == null ? null : XdgNotificationIconFile(icon.path),
defaultAction: "app.event",
defaultActionTarget: payload,
);
} else {
final notificationDetails = NotificationDetails(