chats with most recent messages get moved to the top

This commit is contained in:
DieGurke 2020-07-11 14:18:38 +02:00
parent 77911e8f9a
commit 5caa5381b0

View File

@ -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();