chore: Try out new matrix dart sdk
This commit is contained in:
parent
8613010c5e
commit
55eb23f14d
4 changed files with 18 additions and 28 deletions
|
|
@ -20,8 +20,9 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
..src = 'assets/assets/sounds/notification.ogg'
|
||||
..load();
|
||||
|
||||
void showLocalNotification(EventUpdate eventUpdate) async {
|
||||
final roomId = eventUpdate.roomID;
|
||||
void showLocalNotification(Event event) async {
|
||||
Logs().wtf('NOTIFICATION', event.toJson());
|
||||
final roomId = event.room.id;
|
||||
if (activeRoomId == roomId) {
|
||||
if (kIsWeb && webHasFocus) return;
|
||||
if (PlatformInfos.isDesktop &&
|
||||
|
|
@ -29,19 +30,13 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
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 = room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)));
|
||||
final title =
|
||||
event.room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)));
|
||||
final body = await event.calcLocalizedBody(
|
||||
MatrixLocals(L10n.of(context)),
|
||||
withSenderNamePrefix:
|
||||
!room.isDirectChat || room.lastEvent?.senderId == client.userID,
|
||||
withSenderNamePrefix: !event.room.isDirectChat ||
|
||||
event.room.lastEvent?.senderId == client.userID,
|
||||
plaintextBody: true,
|
||||
hideReply: true,
|
||||
hideEdit: true,
|
||||
|
|
@ -107,14 +102,14 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
.singleWhere((a) => a.name == actionStr);
|
||||
switch (action) {
|
||||
case DesktopNotificationActions.seen:
|
||||
room.setReadMarker(
|
||||
event.room.setReadMarker(
|
||||
event.eventId,
|
||||
mRead: event.eventId,
|
||||
public: AppConfig.sendPublicReadReceipts,
|
||||
);
|
||||
break;
|
||||
case DesktopNotificationActions.openChat:
|
||||
context.go('/rooms/${room.id}');
|
||||
context.go('/rooms/${event.room.id}');
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -305,15 +305,8 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
if (PlatformInfos.isWeb || PlatformInfos.isLinux) {
|
||||
c.onSync.stream.first.then((s) {
|
||||
html.Notification.requestPermission();
|
||||
onNotification[name] ??= c.onEvent.stream
|
||||
.where(
|
||||
(e) =>
|
||||
e.type == EventUpdateType.timeline &&
|
||||
[EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||
.contains(e.content['type']) &&
|
||||
e.content['sender'] != c.userID,
|
||||
)
|
||||
.listen(showLocalNotification);
|
||||
onNotification[name] ??=
|
||||
c.onNotification.stream.listen(showLocalNotification);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1157,10 +1157,11 @@ packages:
|
|||
matrix:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: matrix
|
||||
sha256: de99186797fddbf309dae0d9b9b4d35b49ca10d7bb362727f7cd916ce71a77d7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: b23ad952a445705a200ac4b17b385a602e6fbbe4
|
||||
url: "https://github.com/famedly/matrix-dart-sdk.git"
|
||||
source: git
|
||||
version: "0.36.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ dependencies:
|
|||
just_audio: ^0.9.39
|
||||
latlong2: ^0.9.1
|
||||
linkify: ^5.0.0
|
||||
matrix: ^0.36.0
|
||||
matrix:
|
||||
git: https://github.com/famedly/matrix-dart-sdk.git
|
||||
mime: ^1.0.6
|
||||
native_imaging: ^0.1.1
|
||||
opus_caf_converter_dart: ^1.0.1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue