From 78b560cddd5ca60a35a51ec249f713db51c9cecc Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 27 Jun 2020 09:34:30 +0200 Subject: [PATCH] Made postingPermanentlyDisabled further idiot-proof Additionally deleted annoying alert notifying me that I'm offline. --- .../envoy/client/ui/controller/ChatScene.java | 15 ++++++++++----- .../envoy/client/ui/controller/LoginScene.java | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index 087a23d..66d8305 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -204,7 +204,7 @@ public final class ChatScene { remainingChars .setText(String.format("remaining chars: %d/%d", MAX_MESSAGE_LENGTH - messageTextArea.getText().length(), MAX_MESSAGE_LENGTH)); } - messageTextArea.setDisable(currentChat == null); + messageTextArea.setDisable(currentChat == null || postingPermanentlyDisabled); } /** @@ -256,10 +256,13 @@ public final class ChatScene { || !settings.isEnterToSend() && e.getCode() == KeyCode.ENTER && e.isControlDown())) postMessage(); postButton.setDisable(messageTextArea.getText().isBlank() || currentChat == null); - } else if (!infoLabel.getText().equals("You need to go online to send more messages")) - // Informing the user that he is a f*cking moron and should use Envoy online - // because he ran out of messageIDs to use - updateInfoLabel("You need to go online to send more messages", Color.RED); + } else { + final var noMoreMessaging = "Go online to send messages"; + if (!infoLabel.getText().equals(noMoreMessaging)) + // Informing the user that he is a f*cking moron and should use Envoy online + // because he ran out of messageIDs to use + updateInfoLabel(noMoreMessaging, Color.RED); + } } /** @@ -301,6 +304,8 @@ public final class ChatScene { postingPermanentlyDisabled = !(client.isOnline() || localDB.getIDGenerator().hasNext()); if (postingPermanentlyDisabled) { postButton.setDisable(true); + messageTextArea.setDisable(true); + messageTextArea.clear(); updateInfoLabel("You need to go online to send more messages", Color.RED); return; } diff --git a/src/main/java/envoy/client/ui/controller/LoginScene.java b/src/main/java/envoy/client/ui/controller/LoginScene.java index 020bd43..2bae2dc 100644 --- a/src/main/java/envoy/client/ui/controller/LoginScene.java +++ b/src/main/java/envoy/client/ui/controller/LoginScene.java @@ -159,7 +159,6 @@ public final class LoginScene { final User clientUser = (User) localDB.getUsers().get(credentials.getIdentifier()); if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown"); client.setSender(clientUser); - new Alert(AlertType.WARNING, "A connection to the server could not be established. Starting in offline mode.").showAndWait(); loadChatScene(); } catch (final Exception e) { new Alert(AlertType.ERROR, "Client error: " + e).showAndWait();