From aa3fd49d813e83e8d4eafde4cac832877e78f5e8 Mon Sep 17 00:00:00 2001 From: MhdZiadHirati Date: Wed, 25 Oct 2023 12:22:06 +0300 Subject: [PATCH] chats sorting bug on chatting with old room fixed --- lib/features/chat/business logic layer/chat_controller.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/features/chat/business logic layer/chat_controller.dart b/lib/features/chat/business logic layer/chat_controller.dart index 3b90836..e29cb4f 100644 --- a/lib/features/chat/business logic layer/chat_controller.dart +++ b/lib/features/chat/business logic layer/chat_controller.dart @@ -196,6 +196,11 @@ class ChatController extends GetxController { val.value.data[index].lastMessageDate = currentRoom.value!.messages.data[0].createdAt; } + if (index != 0) { + Room room = val!.value.data[index]; + val.value.data.removeAt(index); + val.value.data.insert(0, room); + } }); rooms.refresh(); }