From 176f6c6463540516d961eb672e7c598d8bde4819 Mon Sep 17 00:00:00 2001 From: delvh Date: Thu, 16 Jul 2020 18:23:06 +0200 Subject: [PATCH] Fixed bug not enabling the post-button when an attachment is present --- .../src/main/java/envoy/client/ui/controller/ChatScene.java | 5 +++-- 1 file changed, 3 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 c431aad..c261ed6 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -355,6 +355,7 @@ public final class ChatScene implements Restorable { try { final var fileBytes = Files.readAllBytes(file.toPath()); pendingAttachment = new Attachment(fileBytes, type); + checkPostConditions(false); // Setting the preview image as image of the attachmentView if (type == AttachmentType.PICTURE) attachmentView.setImage(new Image(new ByteArrayInputStream(fileBytes), DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE, true, true)); @@ -413,9 +414,9 @@ public final class ChatScene implements Restorable { || !settings.isEnterToSend() && e.getCode() == KeyCode.ENTER && e.isControlDown()); } - private void checkPostConditions(boolean sendKeyPressed) { + private void checkPostConditions(boolean postMessage) { if (!postingPermanentlyDisabled) { - if (!postButton.isDisabled() && sendKeyPressed) postMessage(); + if (!postButton.isDisabled() && postMessage) postMessage(); postButton.setDisable(messageTextArea.getText().isBlank() && pendingAttachment == null || currentChat == null); } else { final var noMoreMessaging = "Go online to send messages";