|
1 | 1 | import 'dart:async';
|
2 | 2 | import 'dart:io';
|
3 | 3 |
|
4 |
| -import 'package:http/http.dart' as http; |
5 | 4 | import 'package:collection/collection.dart';
|
6 | 5 | import 'package:flutter/foundation.dart';
|
7 | 6 | import 'package:flutter/widgets.dart' hide Notification;
|
| 7 | +import 'package:http/http.dart' as http; |
8 | 8 |
|
9 | 9 | import '../api/model/model.dart';
|
10 | 10 | import '../api/notifications.dart';
|
@@ -234,6 +234,13 @@ class NotificationDisplayManager {
|
234 | 234 | final groupKey = _groupKey(data);
|
235 | 235 | final conversationKey = _conversationKey(data, groupKey);
|
236 | 236 |
|
| 237 | + final globalStore = await ZulipBinding.instance.getGlobalStore(); |
| 238 | + final account = globalStore.accounts.firstWhereOrNull((account) => |
| 239 | + account.realmUrl == data.realmUrl && account.userId == data.userId); |
| 240 | + if (account == null) { |
| 241 | + return; |
| 242 | + } |
| 243 | + |
237 | 244 | final oldMessagingStyle = await _androidHost
|
238 | 245 | .getActiveNotificationMessagingStyleByTag(conversationKey);
|
239 | 246 |
|
@@ -518,6 +525,16 @@ class NotificationDisplayManager {
|
518 | 525 | }
|
519 | 526 | return null;
|
520 | 527 | }
|
| 528 | + |
| 529 | + static Future<void> removeNotificationsForAccount(Uri realmUri, int userId) async { |
| 530 | + final groupKey = "$realmUri|$userId"; |
| 531 | + final activeNotifications = await _androidHost.getActiveNotifications(desiredExtras: [kExtraLastZulipMessageId]); |
| 532 | + for (final statusBarNotification in activeNotifications) { |
| 533 | + if (statusBarNotification.notification.group == groupKey) { |
| 534 | + await _androidHost.cancel(tag: statusBarNotification.tag, id: statusBarNotification.id); |
| 535 | + } |
| 536 | + } |
| 537 | + } |
521 | 538 | }
|
522 | 539 |
|
523 | 540 | /// The information contained in 'zulip://notification/…' internal
|
|
0 commit comments