mirror of
https://github.com/BlueBubblesApp/bluebubbles-app.git
synced 2025-06-29 03:17:15 +08:00
Fix chat read status getting changed while in the same chat
This commit is contained in:
@ -577,8 +577,10 @@ class Chat {
|
||||
|
||||
Chat toggleHasUnread(bool hasUnread, {bool force = false, bool clearLocalNotifications = true, bool privateMark = true}) {
|
||||
if (hasUnreadMessage == hasUnread && !force) return this;
|
||||
hasUnreadMessage = hasUnread;
|
||||
save(updateHasUnreadMessage: true);
|
||||
if (!cm.isChatActive(guid) || !hasUnread) {
|
||||
hasUnreadMessage = hasUnread;
|
||||
save(updateHasUnreadMessage: true);
|
||||
}
|
||||
|
||||
if (kIsDesktop) {
|
||||
notif.clearDesktopNotificationsForChat(guid);
|
||||
|
@ -134,6 +134,7 @@ class MethodChannelService extends GetxService {
|
||||
}
|
||||
case "markAsRead":
|
||||
case "chat-read-status-changed":
|
||||
if (ls.isAlive) return;
|
||||
await storeStartup.future;
|
||||
Logger.info("Received chat status change from FCM");
|
||||
Map<String, dynamic> data = jsonDecode(call.arguments);
|
||||
|
@ -72,11 +72,11 @@ class SocketService extends GetxService {
|
||||
socket.on("participant-removed", (data) => handleCustomEvent("participant-removed", data));
|
||||
socket.on("participant-added", (data) => handleCustomEvent("participant-added", data));
|
||||
socket.on("participant-left", (data) => handleCustomEvent("participant-left", data));
|
||||
socket.on("chat-read-status-changed", (data) => handleCustomEvent("chat-read-status-change", data));
|
||||
}
|
||||
socket.on("new-message", (data) => handleCustomEvent("new-message", data));
|
||||
socket.on("updated-message", (data) => handleCustomEvent("updated-message", data));
|
||||
socket.on("typing-indicator", (data) => handleCustomEvent("typing-indicator", data));
|
||||
socket.on("chat-read-status-changed", (data) => handleCustomEvent("chat-read-status-change", data));
|
||||
|
||||
socket.connect();
|
||||
}
|
||||
@ -162,10 +162,10 @@ class SocketService extends GetxService {
|
||||
}
|
||||
|
||||
void handleCustomEvent(String event, Map<String, dynamic> data) async {
|
||||
Logger.info("Received $event from socket");
|
||||
switch (event) {
|
||||
case "new-message":
|
||||
if (!isNullOrEmpty(data)!) {
|
||||
Logger.info("Received new message from socket");
|
||||
final message = Message.fromMap(data);
|
||||
if (message.isFromMe!) {
|
||||
if (data['tempGuid'] == null) {
|
||||
@ -181,7 +181,6 @@ class SocketService extends GetxService {
|
||||
return;
|
||||
case "updated-message":
|
||||
if (!isNullOrEmpty(data)!) {
|
||||
Logger.info("Received updated message from socket");
|
||||
inq.queue(IncomingItem.fromMap(QueueType.updatedMessage, data));
|
||||
}
|
||||
return;
|
||||
|
Reference in New Issue
Block a user