@@ -209,15 +209,32 @@ class NotificationDisplayManager {
209
209
}
210
210
211
211
static void _onRemoveFcmMessage (RemoveFcmMessage data) async {
212
+ // We have an FCM message telling us that some Zulip messages were read
213
+ // and should no longer appear as notifications. We'll remove their
214
+ // conversations' notifications, if appropriate, and then the whole
215
+ // notification group if it's now empty.
212
216
assert (debugLog ('notif remove zulipMessageIds: ${data .zulipMessageIds }' ));
213
217
218
+ // There may be a lot of messages mentioned here, across a lot of
219
+ // conversations. But they'll all be for one account, so they'll
220
+ // fall under one notification group.
214
221
final groupKey = _groupKey (data);
215
- final activeNotifications = await _androidHost.getActiveNotifications (
216
- desiredExtras: [kExtraZulipMessageId]);
217
222
223
+ // Find any conversations we can cancel the notification for.
224
+ // The API doesn't lend itself to removing individual messages as
225
+ // they're read, so we wait until we're ready to remove the whole
226
+ // conversation's notification. For background discussion, see:
227
+ // https://github.com/zulip/zulip-mobile/pull/4842#pullrequestreview-725817909
218
228
var haveRemaining = false ;
229
+ final activeNotifications = await _androidHost.getActiveNotifications (
230
+ desiredExtras: [kExtraZulipMessageId]);
219
231
for (final statusBarNotification in activeNotifications) {
220
232
if (statusBarNotification == null ) continue ; // TODO(pigeon) eliminate this case
233
+
234
+ // The StatusBarNotification object describes an active notification in the UI.
235
+ // Its `.tag`, `.id`, and `.notification` are the same values as we passed to
236
+ // [AndroidNotificationHostApi.notify] (and so to `NotificationManager#notify`
237
+ // in the underlying Android APIs). So these are good to match on and inspect.
221
238
final notification = statusBarNotification.notification;
222
239
223
240
// Sadly we don't get toString on Pigeon data classes: flutter#59027
0 commit comments