From 4964c7f6211d9e27d2d018fe41863238227bf13b Mon Sep 17 00:00:00 2001 From: OfficialDakari Date: Sat, 24 May 2025 12:05:05 +0500 Subject: [PATCH] some updates --- lib/pages/chat_list/chat_list.dart | 10 +++------- lib/pages/chat_list/chat_list_body.dart | 4 ++-- lib/pages/chat_list/chat_list_item.dart | 6 ++++-- lib/utils/background_push.dart | 22 ++++++++++++++++++++-- lib/utils/push_helper.dart | 9 ++++++++- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index b238df1..55a0a1f 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -111,13 +111,9 @@ class ChatListController extends State _activeSpaceId = null; }); - void onChatTap( - Room room, [ - BuildContext? posContext, - Room? space, - ]) async { - if (room.membership == Membership.invite && posContext != null) { - chatContextAction(room, posContext, space); + void onChatTap(Room room) async { + if (room.membership == Membership.invite) { + return; } diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index a66a810..7699b7e 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -35,7 +35,7 @@ class ChatListViewBody extends StatelessWidget { key: ValueKey(activeSpace), spaceId: activeSpace, onBack: controller.clearActiveSpace, - onChatTab: (room) => controller.onChatTap(room, context), + onChatTab: (room) => controller.onChatTap(room), onChatContext: (room, context) => controller.chatContextAction(room, context), activeChat: controller.activeChat, @@ -259,7 +259,7 @@ class ChatListViewBody extends StatelessWidget { space: space, key: Key('chat_list_item_${room.id}'), filter: filter, - onTap: () => controller.onChatTap(room, context, space), + onTap: () => controller.onChatTap(room), onLongPress: (context) => controller.chatContextAction(room, context, space), activeChat: controller.activeChat == room.id, diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 6a831f6..c13e0bf 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -93,6 +93,8 @@ class ChatListItem extends StatelessWidget { : room.getState(EventTypes.RoomMember, lastEvent.senderId) == null; final space = this.space; + final inviterMxId = room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId; + return Padding( padding: const EdgeInsets.symmetric( horizontal: 8, @@ -319,7 +321,7 @@ class ChatListItem extends StatelessWidget { ), builder: (context, snapshot) => Text( room.membership == Membership.invite - ? room + ? "${room .getState( EventTypes.RoomMember, room.client.userID!, @@ -329,7 +331,7 @@ class ChatListItem extends StatelessWidget { (isDirectChat ? L10n.of(context).newChatRequest : L10n.of(context) - .inviteGroupChat) + .inviteGroupChat)}${inviterMxId != null ? " ($inviterMxId)" : ""}" : snapshot.data ?? L10n.of(context).emptyChat, softWrap: false, diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index b7fb15d..f79a0a2 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -325,9 +325,12 @@ class BackgroundPush { Future goToRoom(NotificationResponse? response) async { try { - final roomId = response?.payload; + if (response?.payload == null) return; + final arr = response?.payload?.split(' '); + final roomId = arr?[0]; + final eventId = arr?[1]; Logs().v('[Push] Attempting to go to room $roomId...'); - if (roomId == null) { + if (roomId == null || eventId == null) { return; } await client.roomsLoading; @@ -337,6 +340,21 @@ class BackgroundPush { .waitForRoomInSync(roomId) .timeout(const Duration(seconds: 30)); } + if (response?.actionId == "read") { + if (AppConfig.sendPublicReadReceipts) { + await client.setReadMarker(roomId, mRead: eventId); + } else { + await client.setReadMarker(roomId, mReadPrivate: eventId); + } + return; + } else if (response?.actionId == "reply") { + final replyText = response?.input; + final room = client.getRoomById(roomId); + if (replyText != null && room != null) { + await room.sendTextEvent(replyText, inReplyTo: await room.getEventById(eventId)); + } + return; + } FluffyChatApp.router.go( client.getRoomById(roomId)?.membership == Membership.invite ? '/rooms' diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index 21b6bcf..52dc0b4 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -247,6 +247,13 @@ Future _tryPushHelper( number: notification.counts?.unread, category: AndroidNotificationCategory.message, shortcutId: event.room.id, + actions: [ + AndroidNotificationAction("read", l10n.markAsRead), + AndroidNotificationAction("reply", + l10n.reply, inputs: [ + AndroidNotificationActionInput(label: l10n.writeAMessage) + ]) + ], styleInformation: messagingStyleInformation ?? MessagingStyleInformation( Person( @@ -290,7 +297,7 @@ Future _tryPushHelper( title, body, platformChannelSpecifics, - payload: event.roomId, + payload: '${event.roomId} ${event.eventId}', ); Logs().v('Push helper has been completed!'); }