From c0c31e16e4f7d5cc058780a676cba332fe3fd3a1 Mon Sep 17 00:00:00 2001 From: MhdZiadHirati Date: Wed, 25 Oct 2023 13:04:59 +0300 Subject: [PATCH] chat rooms sorting bug fixing --- .../chat/business logic layer/chat_controller.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/features/chat/business logic layer/chat_controller.dart b/lib/features/chat/business logic layer/chat_controller.dart index e29cb4f..1ab116d 100644 --- a/lib/features/chat/business logic layer/chat_controller.dart +++ b/lib/features/chat/business logic layer/chat_controller.dart @@ -196,8 +196,14 @@ class ChatController extends GetxController { val.value.data[index].lastMessageDate = currentRoom.value!.messages.data[0].createdAt; } - if (index != 0) { - Room room = val!.value.data[index]; + if (index != 0 && + (val!.value.data[index].lastMessageDate.hour == DateTime.now().hour && + val.value.data[index].lastMessageDate.day == DateTime.now().day && + val.value.data[index].lastMessageDate.month == + DateTime.now().month && + val.value.data[index].lastMessageDate.year == + DateTime.now().year)) { + Room room = val.value.data[index]; val.value.data.removeAt(index); val.value.data.insert(0, room); }