Skip to content

Commit a79adc2

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

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.
@@ -36,7 +37,7 @@ class NotificationOpenService {
3637

3738
assert(debugLog('got notif: url: $url'));
3839
assert(url.scheme == 'zulip' && url.host == 'notification');
39-
final payload = NotificationOpenPayload.parseUrl(url);
40+
final payload = NotificationOpenPayload.parseAndroidNotificationUrl(url);
4041

4142
final account = globalStore.accounts.firstWhereOrNull(
4243
(account) => account.realmUrl.origin == payload.realmUrl.origin
@@ -57,8 +58,8 @@ class NotificationOpenService {
5758

5859
/// Navigates to the [MessageListPage] of the specific conversation
5960
/// given the `zulip://notification/…` Android intent data URL,
60-
/// generated with [NotificationOpenPayload.buildUrl] while creating
61-
/// the notification.
61+
/// generated with [NotificationOpenPayload.buildAndroidNotificationUrl]
62+
/// while creating the notification.
6263
static Future<void> navigateForNotification(Uri url) async {
6364
assert(defaultTargetPlatform == TargetPlatform.android);
6465
assert(debugLog('opened notif: url: $url'));
@@ -76,8 +77,8 @@ class NotificationOpenService {
7677
}
7778
}
7879

79-
/// The information contained in 'zulip://notification/…' internal
80-
/// Android intent data URL, used for notification-open flow.
80+
/// The data from a notification that describes what to do
81+
/// when the user opens the notification.
8182
class NotificationOpenPayload {
8283
final Uri realmUrl;
8384
final int userId;
@@ -89,7 +90,10 @@ class NotificationOpenPayload {
8990
required this.narrow,
9091
});
9192

92-
factory NotificationOpenPayload.parseUrl(Uri url) {
93+
/// Parses the internal Android notification url, that was created using
94+
/// [buildAndroidNotificationUrl], and retrieves the information required
95+
/// for navigation.
96+
factory NotificationOpenPayload.parseAndroidNotificationUrl(Uri url) {
9397
if (url case Uri(
9498
scheme: 'zulip',
9599
host: 'notification',
@@ -135,7 +139,7 @@ class NotificationOpenPayload {
135139
}
136140
}
137141

138-
Uri buildUrl() {
142+
Uri buildAndroidNotificationUrl() {
139143
return Uri(
140144
scheme: 'zulip',
141145
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)