From 8b9b0d63c7530eb17a1bc6589f5923a2e64a70c9 Mon Sep 17 00:00:00 2001 From: delvh Date: Fri, 7 Feb 2020 15:57:41 +0100 Subject: [PATCH] Redesigned UserStatusChangeProcessor to please @CyB3RC0nN0R s wishes --- .../envoy/client/net/UserStatusChangeProcessor.java | 11 ++++------- src/main/java/envoy/client/ui/ChatWindow.java | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/envoy/client/net/UserStatusChangeProcessor.java b/src/main/java/envoy/client/net/UserStatusChangeProcessor.java index 280c834..744e6e8 100644 --- a/src/main/java/envoy/client/net/UserStatusChangeProcessor.java +++ b/src/main/java/envoy/client/net/UserStatusChangeProcessor.java @@ -1,11 +1,9 @@ package envoy.client.net; -import java.util.List; import java.util.function.Consumer; import java.util.logging.Logger; import envoy.client.util.EnvoyLog; -import envoy.data.User; import envoy.event.EventBus; import envoy.event.UserStatusChangeEvent; @@ -19,8 +17,9 @@ import envoy.event.UserStatusChangeEvent; */ public class UserStatusChangeProcessor implements Consumer { - private static final Logger logger = EnvoyLog.getLogger(UserStatusChangeProcessor.class.getSimpleName()); - private Client client; + private Client client; + + private static final Logger logger = EnvoyLog.getLogger(UserStatusChangeProcessor.class.getSimpleName()); /** * @param client the {@link Client} who receives an @@ -32,9 +31,7 @@ public class UserStatusChangeProcessor implements Consumer contacts = client.getContacts().getContacts(); - contacts.stream().filter((user) -> user.getId() == evt.getId()).findFirst().get().setStatus(evt.get()); + client.getContacts().getContacts().stream().filter((user) -> user.getId() == evt.getId()).findFirst().get().setStatus(evt.get()); EventBus.getInstance().dispatch(evt); } - } diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 8a7723e..0e12611 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -212,7 +212,7 @@ public class ChatWindow extends JFrame { // Listen to theme changes EventBus.getInstance().register(ThemeChangeEvent.class, (evt) -> applyTheme((Theme) evt.get())); - // Listen to UserStatus changes + // Listen to user status changes EventBus.getInstance().register(UserStatusChangeEvent.class, (evt) -> { userList.revalidate(); userList.repaint(); }); // Listen to received messages