fix: Missing null check in background push

This commit is contained in:
Sorunome 2021-09-16 21:09:57 +02:00
parent cbb40b6fdb
commit 7dc762ee1f
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
1 changed files with 11 additions and 6 deletions

View File

@ -519,7 +519,8 @@ class BackgroundPush {
});
if (!syncErrored) {
emptyRooms = client.rooms
.where((r) => r.notificationCount == 0)
.where((r) =>
r.notificationCount == 0 || r.notificationCount == null)
.map((r) => r.id);
}
}
@ -538,13 +539,15 @@ class BackgroundPush {
'[Push] failed to fetch pending notifications for clearing push, falling back...',
e);
emptyRooms = client.rooms
.where((r) => r.notificationCount == 0)
.where((r) =>
r.notificationCount == 0 || r.notificationCount == null)
.map((r) => r.id);
}
}
} else {
emptyRooms = client.rooms
.where((r) => r.notificationCount == 0)
.where(
(r) => r.notificationCount == 0 || r.notificationCount == null)
.map((r) => r.id);
}
await _loadIdMap();
@ -580,7 +583,8 @@ class BackgroundPush {
if (((activeRoomId?.isNotEmpty ?? false) &&
activeRoomId == room.id &&
client.syncPresence == null) ||
(event != null && room.notificationCount == 0)) {
(event != null &&
(room.notificationCount == 0 || room.notificationCount == null))) {
return;
}
@ -589,10 +593,11 @@ class BackgroundPush {
// Count all unread events
var unreadEvents = 0;
client.rooms.forEach((Room room) => unreadEvents += room.notificationCount);
client.rooms
.forEach((Room room) => unreadEvents += room.notificationCount ?? 0);
// Calculate title
final title = l10n.unreadMessages(room.notificationCount);
final title = l10n.unreadMessages(room.notificationCount ?? 0);
// Calculate the body
final body = event.getLocalizedBody(