Made postingPermanentlyDisabled further idiot-proof

Additionally deleted annoying alert notifying me that I'm offline.
This commit is contained in:
delvh 2020-06-27 09:34:30 +02:00
parent bc230575f4
commit 5a933fab4e
2 changed files with 10 additions and 6 deletions

View File

@ -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;
}

View File

@ -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();