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:
parent
da6bdafc68
commit
7ca770cbc3
@ -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 -> {
|
||||||
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(() -> {
|
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);
|
chats.getSource().remove(chat);
|
||||||
((ObservableList<Chat>) chats.getSource()).add(0, chat);
|
((ObservableList<Chat>) chats.getSource()).add(0, chat);
|
||||||
|
|
||||||
|
@ -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" />
|
||||||
|
Reference in New Issue
Block a user