@@ -17,31 +17,23 @@ import '../widgets/store.dart';
1717/// Responds to the user opening a notification.
1818class NotificationOpenService {
1919
20- /// Provides the route and the account ID by parsing the notification URL.
21- ///
22- /// The URL must have been generated using
23- /// [NotificationOpenPayload.buildAndroidNotificationUrl] while creating the
24- /// notification.
20+ /// Provides the route to open by parsing the notification payload.
2521 ///
2622 /// Returns null and shows an error dialog if the associated account is not
2723 /// found in the global store.
2824 ///
2925 /// The context argument should be a descendant of the app's main [Navigator] .
3026 static AccountRoute <void >? routeForNotification ({
3127 required BuildContext context,
32- required Uri url ,
28+ required NotificationOpenPayload data ,
3329 }) {
3430 assert (defaultTargetPlatform == TargetPlatform .android);
3531
3632 final globalStore = GlobalStoreWidget .of (context);
3733
38- assert (debugLog ('got notif: url: $url ' ));
39- assert (url.scheme == 'zulip' && url.host == 'notification' );
40- final payload = NotificationOpenPayload .parseAndroidNotificationUrl (url);
41-
4234 final account = globalStore.accounts.firstWhereOrNull (
43- (account) => account.realmUrl.origin == payload .realmUrl.origin
44- && account.userId == payload .userId);
35+ (account) => account.realmUrl.origin == data .realmUrl.origin
36+ && account.userId == data .userId);
4537 if (account == null ) { // TODO(log)
4638 final zulipLocalizations = ZulipLocalizations .of (context);
4739 showErrorDialog (context: context,
@@ -53,14 +45,14 @@ class NotificationOpenService {
5345 return MessageListPage .buildRoute (
5446 accountId: account.id,
5547 // TODO(#82): Open at specific message, not just conversation
56- narrow: payload .narrow);
48+ narrow: data .narrow);
5749 }
5850
5951 /// Navigates to the [MessageListPage] of the specific conversation
6052 /// given the `zulip://notification/…` Android intent data URL,
6153 /// generated with [NotificationOpenPayload.buildAndroidNotificationUrl]
6254 /// while creating the notification.
63- static Future <void > navigateForNotification (Uri url) async {
55+ static Future <void > navigateForAndroidNotificationUrl (Uri url) async {
6456 assert (defaultTargetPlatform == TargetPlatform .android);
6557 assert (debugLog ('opened notif: url: $url ' ));
6658
@@ -69,7 +61,9 @@ class NotificationOpenService {
6961 assert (context.mounted);
7062 if (! context.mounted) return ; // TODO(linter): this is impossible as there's no actual async gap, but the use_build_context_synchronously lint doesn't see that
7163
72- final route = routeForNotification (context: context, url: url);
64+ assert (url.scheme == 'zulip' && url.host == 'notification' );
65+ final data = NotificationOpenPayload .parseAndroidNotificationUrl (url);
66+ final route = routeForNotification (context: context, data: data);
7367 if (route == null ) return ; // TODO(log)
7468
7569 // TODO(nav): Better interact with existing nav stack on notif open
0 commit comments