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 9111880dcf
commit b5e83272a6

View File

@ -232,7 +232,7 @@ public final class ChatScene implements Restorable {
currentChat = localDB.getChat(user.getID()).get();
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);
logger.log(Level.FINEST, "Loading chat with " + user + " at index " + scrollIndex);
deleteContactMenuItem.setText("Delete " + user.getName());