|
|
@ -20,8 +20,9 @@ extension LocalNotificationsExtension on MatrixState {
|
|
|
|
..src = 'assets/assets/sounds/notification.ogg'
|
|
|
|
..src = 'assets/assets/sounds/notification.ogg'
|
|
|
|
..load();
|
|
|
|
..load();
|
|
|
|
|
|
|
|
|
|
|
|
void showLocalNotification(EventUpdate eventUpdate) async {
|
|
|
|
void showLocalNotification(Event event) async {
|
|
|
|
final roomId = eventUpdate.roomID;
|
|
|
|
Logs().wtf('NOTIFICATION', event.toJson());
|
|
|
|
|
|
|
|
final roomId = event.room.id;
|
|
|
|
if (activeRoomId == roomId) {
|
|
|
|
if (activeRoomId == roomId) {
|
|
|
|
if (kIsWeb && webHasFocus) return;
|
|
|
|
if (kIsWeb && webHasFocus) return;
|
|
|
|
if (PlatformInfos.isDesktop &&
|
|
|
|
if (PlatformInfos.isDesktop &&
|
|
|
@ -29,19 +30,13 @@ extension LocalNotificationsExtension on MatrixState {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final room = client.getRoomById(roomId);
|
|
|
|
|
|
|
|
if (room == null) {
|
|
|
|
|
|
|
|
Logs().w('Can not display notification for unknown room $roomId');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (room.notificationCount == 0) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final event = Event.fromJson(eventUpdate.content, room);
|
|
|
|
final title =
|
|
|
|
final title = room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)));
|
|
|
|
event.room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)));
|
|
|
|
final body = await event.calcLocalizedBody(
|
|
|
|
final body = await event.calcLocalizedBody(
|
|
|
|
MatrixLocals(L10n.of(context)),
|
|
|
|
MatrixLocals(L10n.of(context)),
|
|
|
|
withSenderNamePrefix:
|
|
|
|
withSenderNamePrefix: !event.room.isDirectChat ||
|
|
|
|
!room.isDirectChat || room.lastEvent?.senderId == client.userID,
|
|
|
|
event.room.lastEvent?.senderId == client.userID,
|
|
|
|
plaintextBody: true,
|
|
|
|
plaintextBody: true,
|
|
|
|
hideReply: true,
|
|
|
|
hideReply: true,
|
|
|
|
hideEdit: true,
|
|
|
|
hideEdit: true,
|
|
|
@ -107,14 +102,14 @@ extension LocalNotificationsExtension on MatrixState {
|
|
|
|
.singleWhere((a) => a.name == actionStr);
|
|
|
|
.singleWhere((a) => a.name == actionStr);
|
|
|
|
switch (action) {
|
|
|
|
switch (action) {
|
|
|
|
case DesktopNotificationActions.seen:
|
|
|
|
case DesktopNotificationActions.seen:
|
|
|
|
room.setReadMarker(
|
|
|
|
event.room.setReadMarker(
|
|
|
|
event.eventId,
|
|
|
|
event.eventId,
|
|
|
|
mRead: event.eventId,
|
|
|
|
mRead: event.eventId,
|
|
|
|
public: AppConfig.sendPublicReadReceipts,
|
|
|
|
public: AppConfig.sendPublicReadReceipts,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DesktopNotificationActions.openChat:
|
|
|
|
case DesktopNotificationActions.openChat:
|
|
|
|
context.go('/rooms/${room.id}');
|
|
|
|
context.go('/rooms/${event.room.id}');
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|