From c5094e52cd918f803568c89699b06a286938314b Mon Sep 17 00:00:00 2001 From: delvh Date: Wed, 15 Jul 2020 21:44:57 +0200 Subject: [PATCH] Fixed bug not scrolling to the correct message --- .../src/main/java/envoy/client/ui/controller/ChatScene.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/controller/ChatScene.java b/client/src/main/java/envoy/client/ui/controller/ChatScene.java index 920d93f..e5c1931 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -184,7 +184,7 @@ public final class ChatScene implements Restorable { switch (e.getOperationType()) { case ADD: localDB.getUsers().put(contact.getName(), contact); - Chat chat = contact instanceof User ? new Chat(contact) : new GroupChat(client.getSender(), contact); + final Chat chat = contact instanceof User ? new Chat(contact) : new GroupChat(client.getSender(), contact); Platform.runLater(() -> chatList.getItems().add(chat)); break; case REMOVE: @@ -240,7 +240,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() - currentChat.getUnreadAmount() - 1; + final var scrollIndex = messageList.getItems().size() - currentChat.getUnreadAmount(); messageList.scrollTo(scrollIndex); logger.log(Level.FINEST, "Loading chat with " + user + " at index " + scrollIndex); deleteContactMenuItem.setText("Delete " + user.getName());