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 <kai@kske.dev>
Reviewed-by: DieGurke <maxi@kske.dev>
This commit is contained in:
Leon Hofmeister 2020-10-05 18:50:45 +02:00
parent da6bdafc68
commit 7ca770cbc3
Signed by: Käfer & Engelbart Git
GPG Key ID: 70F2F9206EDC1FCE
2 changed files with 14 additions and 10 deletions

View File

@ -223,16 +223,16 @@ public final class ChatScene implements EventListener, Restorable {
final var recipientID = message instanceof GroupMessage || ownMessage ? message.getRecipientID() : message.getSenderID(); final var recipientID = message instanceof GroupMessage || ownMessage ? message.getRecipientID() : message.getSenderID();
localDB.getChat(recipientID).ifPresent(chat -> { localDB.getChat(recipientID).ifPresent(chat -> {
Platform.runLater(() -> {
chat.insert(message); chat.insert(message);
// Read current chat or increment unread amount // Read current chat or increment unread amount
if (chat.equals(currentChat)) { if (chat.equals(currentChat)) {
currentChat.read(writeProxy); currentChat.read(writeProxy);
Platform.runLater(this::scrollToMessageListEnd); scrollToMessageListEnd();
} else if (!ownMessage && message.getStatus() != MessageStatus.READ) chat.incrementUnreadAmount(); } else if (!ownMessage && message.getStatus() != MessageStatus.READ) chat.incrementUnreadAmount();
// Move chat with most recent unread messages to the top // Move chat with most recent unread messages to the top
Platform.runLater(() -> {
chats.getSource().remove(chat); chats.getSource().remove(chat);
((ObservableList<Chat>) chats.getSource()).add(0, chat); ((ObservableList<Chat>) chats.getSource()).add(0, chat);

View File

@ -20,13 +20,17 @@
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import javafx.stage.Screen?>
<GridPane fx:id="scene" maxHeight="-Infinity" <GridPane fx:id="scene" maxHeight="-Infinity"
maxWidth="-Infinity" minHeight="400.0" minWidth="500.0" maxWidth="-Infinity" minHeight="400.0" minWidth="500.0"
prefHeight="1152.0" prefWidth="2042.0" prefHeight="${screen.visualBounds.height}" prefWidth="${screen.visualBounds.width}"
xmlns="http://javafx.com/javafx/11.0.1" xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="envoy.client.ui.controller.ChatScene"> fx:controller="envoy.client.ui.controller.ChatScene">
<fx:define>
<Screen fx:factory="getPrimary" fx:id="screen" />
</fx:define>
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="NEVER" <ColumnConstraints hgrow="NEVER"
maxWidth="327.99997965494794" minWidth="-Infinity" prefWidth="317.0" /> maxWidth="327.99997965494794" minWidth="-Infinity" prefWidth="317.0" />