Skip to content

Commit aa5c31d

Browse files
committed
notif [nfc]: Clarify meaning of last-message-ID extra
Each notification can be showing several Zulip messages. This extra carries the message ID of specifically the latest one.
1 parent f2c8e40 commit aa5c31d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/notifications/display.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class NotificationDisplayManager {
159159
number: messagingStyle.messages.length,
160160
extras: {
161161
// Used to decide when a `RemoveFcmMessage` event should clear this notification.
162-
kExtraZulipMessageId: data.zulipMessageId.toString(),
162+
kExtraLastZulipMessageId: data.zulipMessageId.toString(),
163163
},
164164

165165
contentIntent: PendingIntent(
@@ -227,7 +227,7 @@ class NotificationDisplayManager {
227227
// https://github.com/zulip/zulip-mobile/pull/4842#pullrequestreview-725817909
228228
var haveRemaining = false;
229229
final activeNotifications = await _androidHost.getActiveNotifications(
230-
desiredExtras: [kExtraZulipMessageId]);
230+
desiredExtras: [kExtraLastZulipMessageId]);
231231
for (final statusBarNotification in activeNotifications) {
232232
if (statusBarNotification == null) continue; // TODO(pigeon) eliminate this case
233233

@@ -248,7 +248,7 @@ class NotificationDisplayManager {
248248
// Don't act on the summary notification for the group.
249249
if (statusBarNotification.tag == groupKey) continue;
250250

251-
final lastMessageIdStr = notification.extras[kExtraZulipMessageId];
251+
final lastMessageIdStr = notification.extras[kExtraLastZulipMessageId];
252252
assert(lastMessageIdStr != null);
253253
if (lastMessageIdStr == null) continue; // TODO(log)
254254
final lastMessageId = int.parse(lastMessageIdStr, radix: 10);
@@ -277,13 +277,13 @@ class NotificationDisplayManager {
277277
}
278278
}
279279

280-
/// The key for the message-id entry in [Notification.extras] metadata.
280+
/// A key we use in [Notification.extras] for the [Message.id] of the
281+
/// latest Zulip message in the notification's conversation.
281282
///
282-
/// Currently, it is used to store the message-id in the respective
283-
/// notification which is later fetched to determine if a [RemoveFcmMessage]
284-
/// event should clear that specific notification.
283+
/// We use this to determine if a [RemoveFcmMessage] event should
284+
/// clear that specific notification.
285285
@visibleForTesting
286-
static const kExtraZulipMessageId = 'zulipMessageId';
286+
static const kExtraLastZulipMessageId = 'lastZulipMessageId';
287287

288288
/// A notification ID, derived as a hash of the given string key.
289289
///

test/notifications/display_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void main() {
187187
..smallIconResourceName.equals('zulip_notification')
188188
..extras.which((it) => it.isNotNull()
189189
..deepEquals(<String, String>{
190-
NotificationDisplayManager.kExtraZulipMessageId: data.zulipMessageId.toString(),
190+
NotificationDisplayManager.kExtraLastZulipMessageId: data.zulipMessageId.toString(),
191191
}))
192192
..groupKey.equals(expectedGroupKey)
193193
..isGroupSummary.isNull()
@@ -258,7 +258,7 @@ void main() {
258258
..notification.which((it) => it
259259
..group.equals(expectedGroupKey)
260260
..extras.deepEquals(<String, String>{
261-
NotificationDisplayManager.kExtraZulipMessageId: data.zulipMessageId.toString(),
261+
NotificationDisplayManager.kExtraLastZulipMessageId: data.zulipMessageId.toString(),
262262
}))
263263
..tag.equals(expectedTag);
264264
}

0 commit comments

Comments
 (0)