From ba4fdbe2f451db6933033a0477c0f4fef73a60fa Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sat, 11 Jul 2020 14:18:38 +0200 Subject: [PATCH] chats with most recent messages get moved to the top --- .../envoy/client/ui/controller/ChatScene.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index 4175f17..1c626b2 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -135,6 +135,13 @@ public final class ChatScene implements Restorable { } Platform.runLater(() -> { messageList.refresh(); scrollToMessageListEnd(); }); } + // Moving chat with most recent unreadMessages to the top + Platform.runLater(() -> { + userList.getItems().remove(chat); + userList.getItems().add(0, chat); + localDB.getChats().remove(chat); + localDB.getChats().add(0, chat); + }); userList.refresh(); }); }); @@ -453,6 +460,14 @@ public final class ChatScene implements Restorable { // Add message to LocalDB and update UI currentChat.insert(message); + // Moving currentChat to the top + Platform.runLater(() -> { + userList.getItems().remove(currentChat); + userList.getItems().add(0, currentChat); + userList.getSelectionModel().select(0); + localDB.getChats().remove(currentChat); + localDB.getChats().add(0, currentChat); + }); messageList.refresh(); scrollToMessageListEnd();