From 84fd2229565437d3a7d1184cf024e30e0b71f501 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Wed, 12 Feb 2020 22:22:29 +0100 Subject: [PATCH] Fixed entering offline mode --- src/main/java/envoy/client/ui/LoginDialog.java | 7 ++----- src/main/java/envoy/client/ui/Startup.java | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/envoy/client/ui/LoginDialog.java b/src/main/java/envoy/client/ui/LoginDialog.java index bdac73a..40991c6 100644 --- a/src/main/java/envoy/client/ui/LoginDialog.java +++ b/src/main/java/envoy/client/ui/LoginDialog.java @@ -101,8 +101,7 @@ public class LoginDialog extends JDialog { // Listen to handshake rejections EventBus.getInstance().register(HandshakeRejectionEvent.class, evt -> { - for (Component c : contentPanel.getComponents()) - if (c == errorMessage) contentPanel.remove(errorMessage); + if (errorMessage != null) contentPanel.remove(errorMessage); clearPasswordFields(); errorMessage = new JLabel(evt.get()); gbc_errorMessage = new GridBagConstraints(); @@ -135,9 +134,7 @@ public class LoginDialog extends JDialog { client.initReceiver(localDb, receivedMessageCache); dispose(); } - } catch (IOException | InterruptedException e) { - e.printStackTrace(); - } catch (TimeLimitExceededException e) { + } catch (IOException | InterruptedException | TimeLimitExceededException e) { logger.warning("Could not connect to server. Trying offline mode..."); e.printStackTrace(); try { diff --git a/src/main/java/envoy/client/ui/Startup.java b/src/main/java/envoy/client/ui/Startup.java index a684326..5427fe1 100644 --- a/src/main/java/envoy/client/ui/Startup.java +++ b/src/main/java/envoy/client/ui/Startup.java @@ -101,7 +101,6 @@ public class Startup { // Set client user in local database localDb.setUser(client.getSender()); - // Initialize chats in local database try { localDb.initializeUserStorage();