Fixed bug not scrolling to the correct message
This commit is contained in:
parent
9a9a475c0e
commit
c5094e52cd
@ -184,7 +184,7 @@ public final class ChatScene implements Restorable {
|
|||||||
switch (e.getOperationType()) {
|
switch (e.getOperationType()) {
|
||||||
case ADD:
|
case ADD:
|
||||||
localDB.getUsers().put(contact.getName(), contact);
|
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));
|
Platform.runLater(() -> chatList.getItems().add(chat));
|
||||||
break;
|
break;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
@ -240,7 +240,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() - currentChat.getUnreadAmount() - 1;
|
final var scrollIndex = messageList.getItems().size() - currentChat.getUnreadAmount();
|
||||||
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());
|
||||||
|
Reference in New Issue
Block a user