From 7ca770cbc3aee182855d31429d27fbb74f2156b9 Mon Sep 17 00:00:00 2001 From: delvh Date: Mon, 5 Oct 2020 18:50:45 +0200 Subject: [PATCH] Fix Incorrect ChatScene Size on Startup (#79) Additionally fixes error on message receival. Fixes #68 Reviewed-on: https://git.kske.dev/zdm/envoy/pulls/79 Reviewed-by: kske Reviewed-by: DieGurke --- .../envoy/client/ui/controller/ChatScene.java | 18 +++++++++--------- client/src/main/resources/fxml/ChatScene.fxml | 6 +++++- 2 files changed, 14 insertions(+), 10 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 8ec0246..a8efa6c 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -223,16 +223,16 @@ public final class ChatScene implements EventListener, Restorable { final var recipientID = message instanceof GroupMessage || ownMessage ? message.getRecipientID() : message.getSenderID(); localDB.getChat(recipientID).ifPresent(chat -> { - chat.insert(message); - - // Read current chat or increment unread amount - if (chat.equals(currentChat)) { - currentChat.read(writeProxy); - Platform.runLater(this::scrollToMessageListEnd); - } else if (!ownMessage && message.getStatus() != MessageStatus.READ) chat.incrementUnreadAmount(); - - // Move chat with most recent unread messages to the top Platform.runLater(() -> { + chat.insert(message); + + // Read current chat or increment unread amount + if (chat.equals(currentChat)) { + currentChat.read(writeProxy); + scrollToMessageListEnd(); + } else if (!ownMessage && message.getStatus() != MessageStatus.READ) chat.incrementUnreadAmount(); + + // Move chat with most recent unread messages to the top chats.getSource().remove(chat); ((ObservableList) chats.getSource()).add(0, chat); diff --git a/client/src/main/resources/fxml/ChatScene.fxml b/client/src/main/resources/fxml/ChatScene.fxml index e3de7aa..f557974 100644 --- a/client/src/main/resources/fxml/ChatScene.fxml +++ b/client/src/main/resources/fxml/ChatScene.fxml @@ -20,13 +20,17 @@ + + + +