When opening a chat holding unread messages, it scrolls to the first one

This commit is contained in:
DieGurke 2020-07-11 14:57:15 +02:00
parent 0cebaeacb5
commit 0b0b240fb1

View File

@ -232,7 +232,7 @@ public final class ChatScene implements Restorable {
currentChat = localDB.getChat(user.getID()).get(); currentChat = localDB.getChat(user.getID()).get();
messageList.setItems(FXCollections.observableList(currentChat.getMessages())); messageList.setItems(FXCollections.observableList(currentChat.getMessages()));
final var scrollIndex = messageList.getItems().size() - 1; final var scrollIndex = messageList.getItems().size() - currentChat.getUnreadAmount() - 1;
messageList.scrollTo(scrollIndex); messageList.scrollTo(scrollIndex);
logger.log(Level.FINEST, "Loading chat with " + user + " at index " + scrollIndex); logger.log(Level.FINEST, "Loading chat with " + user + " at index " + scrollIndex);
deleteContactMenuItem.setText("Delete " + user.getName()); deleteContactMenuItem.setText("Delete " + user.getName());