Redesigned UserStatusChangeProcessor to please @CyB3RC0nN0R s wishes

This commit is contained in:
delvh 2020-02-07 15:57:41 +01:00
parent f9ce464aaa
commit 8b9b0d63c7
2 changed files with 5 additions and 8 deletions

View File

@ -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<UserStatusChangeEvent> {
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<UserStatusChangeEvent
@Override
public void accept(UserStatusChangeEvent evt) {
logger.info("Received " + evt);
List<User> 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);
}
}

View File

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