Redesigned UserStatusChangeProcessor to please @CyB3RC0nN0R s wishes
This commit is contained in:
parent
f28d4e2e55
commit
337c74ded1
@ -1,11 +1,9 @@
|
|||||||
package envoy.client.net;
|
package envoy.client.net;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import envoy.client.util.EnvoyLog;
|
import envoy.client.util.EnvoyLog;
|
||||||
import envoy.data.User;
|
|
||||||
import envoy.event.EventBus;
|
import envoy.event.EventBus;
|
||||||
import envoy.event.UserStatusChangeEvent;
|
import envoy.event.UserStatusChangeEvent;
|
||||||
|
|
||||||
@ -19,9 +17,10 @@ import envoy.event.UserStatusChangeEvent;
|
|||||||
*/
|
*/
|
||||||
public class UserStatusChangeProcessor implements Consumer<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
|
* @param client the {@link Client} who receives an
|
||||||
* {@link UserStatusChangeEvent}
|
* {@link UserStatusChangeEvent}
|
||||||
@ -32,9 +31,7 @@ public class UserStatusChangeProcessor implements Consumer<UserStatusChangeEvent
|
|||||||
@Override
|
@Override
|
||||||
public void accept(UserStatusChangeEvent evt) {
|
public void accept(UserStatusChangeEvent evt) {
|
||||||
logger.info("Received " + evt);
|
logger.info("Received " + evt);
|
||||||
List<User> contacts = client.getContacts().getContacts();
|
client.getContacts().getContacts().stream().filter((user) -> user.getId() == evt.getId()).findFirst().get().setStatus(evt.get());
|
||||||
contacts.stream().filter((user) -> user.getId() == evt.getId()).findFirst().get().setStatus(evt.get());
|
|
||||||
EventBus.getInstance().dispatch(evt);
|
EventBus.getInstance().dispatch(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ public class ChatWindow extends JFrame {
|
|||||||
// Listen to theme changes
|
// Listen to theme changes
|
||||||
EventBus.getInstance().register(ThemeChangeEvent.class, (evt) -> applyTheme((Theme) evt.get()));
|
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(); });
|
EventBus.getInstance().register(UserStatusChangeEvent.class, (evt) -> { userList.revalidate(); userList.repaint(); });
|
||||||
|
|
||||||
// Listen to received messages
|
// Listen to received messages
|
||||||
|
Reference in New Issue
Block a user