Skip to content

Commit a3ea5a3

Browse files
notif [nfc]: Rename NotificationOpenPayload methods
To make it clear that they are Android specific.
1 parent 9ba2bf7 commit a3ea5a3

File tree

4 files changed

+188
-180
lines changed

4 files changed

+188
-180
lines changed

lib/notifications/display.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class NotificationDisplayManager {
296296
TopicNarrow(streamId, topic),
297297
FcmMessageDmRecipient(:var allRecipientIds) =>
298298
DmNarrow(allRecipientIds: allRecipientIds, selfUserId: data.userId),
299-
}).buildUrl();
299+
}).buildAndroidNotificationUrl();
300300

301301
await _androidHost.notify(
302302
id: kNotificationId,

lib/notifications/open.dart

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class NotificationOpenService {
1919

2020
/// Provides the route and the account ID by parsing the notification URL.
2121
///
22-
/// The URL must have been generated using [NotificationOpenPayload.buildUrl]
23-
/// while creating the notification.
22+
/// The URL must have been generated using
23+
/// [NotificationOpenPayload.buildAndroidNotificationUrl] while creating the
24+
/// notification.
2425
///
2526
/// Returns null and shows an error dialog if the associated account is not
2627
/// found in the global store.
@@ -34,7 +35,7 @@ class NotificationOpenService {
3435

3536
assert(debugLog('got notif: url: $url'));
3637
assert(url.scheme == 'zulip' && url.host == 'notification');
37-
final payload = NotificationOpenPayload.parseUrl(url);
38+
final payload = NotificationOpenPayload.parseAndroidNotificationUrl(url);
3839

3940
final account = globalStore.accounts.firstWhereOrNull(
4041
(account) => account.realmUrl.origin == payload.realmUrl.origin
@@ -55,8 +56,8 @@ class NotificationOpenService {
5556

5657
/// Navigates to the [MessageListPage] of the specific conversation
5758
/// given the `zulip://notification/…` Android intent data URL,
58-
/// generated with [NotificationOpenPayload.buildUrl] while creating
59-
/// the notification.
59+
/// generated with [NotificationOpenPayload.buildAndroidNotificationUrl]
60+
/// while creating the notification.
6061
static Future<void> navigateForNotification(Uri url) async {
6162
assert(defaultTargetPlatform == TargetPlatform.android);
6263
assert(debugLog('opened notif: url: $url'));
@@ -74,8 +75,8 @@ class NotificationOpenService {
7475
}
7576
}
7677

77-
/// The information contained in 'zulip://notification/…' internal
78-
/// Android intent data URL, used for notification-open flow.
78+
/// The data from a notification that describes what to do
79+
/// when the user opens the notification.
7980
class NotificationOpenPayload {
8081
final Uri realmUrl;
8182
final int userId;
@@ -87,7 +88,10 @@ class NotificationOpenPayload {
8788
required this.narrow,
8889
});
8990

90-
factory NotificationOpenPayload.parseUrl(Uri url) {
91+
/// Parses the internal Android notification url, that was created using
92+
/// [buildAndroidNotificationUrl], and retrieves the information required
93+
/// for navigation.
94+
factory NotificationOpenPayload.parseAndroidNotificationUrl(Uri url) {
9195
if (url case Uri(
9296
scheme: 'zulip',
9397
host: 'notification',
@@ -133,7 +137,7 @@ class NotificationOpenPayload {
133137
}
134138
}
135139

136-
Uri buildUrl() {
140+
Uri buildAndroidNotificationUrl() {
137141
return Uri(
138142
scheme: 'zulip',
139143
host: 'notification',

test/notifications/display_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ void main() {
343343
TopicNarrow(streamId, topic),
344344
FcmMessageDmRecipient(:var allRecipientIds) =>
345345
DmNarrow(allRecipientIds: allRecipientIds, selfUserId: data.userId),
346-
}).buildUrl();
346+
}).buildAndroidNotificationUrl();
347347

348348
final messageStyleMessagesChecks =
349349
messageStyleMessages.mapIndexed((i, messageData) {

0 commit comments

Comments
 (0)