Update UI on user status change

This commit is contained in:
Kai S. K. Engelbart 2020-09-26 12:10:22 +02:00
parent 6d7afbaa8f
commit 5daff3620e
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
2 changed files with 7 additions and 9 deletions

View File

@ -222,6 +222,11 @@ public final class LocalDB implements EventListener {
this.<GroupMessage>getMessage(evt.getID()).ifPresent(msg -> msg.getMemberStatuses().replace(evt.getMemberID(), evt.get()));
}
@Event(priority = 150)
private void onUserStatusChange(UserStatusChange evt) {
this.getChat(evt.getID()).map(Chat::getRecipient).map(User.class::cast).ifPresent(u -> u.setStatus(evt.get()));
}
@Event(priority = 150)
private void onGroupResize(GroupResize evt) { getChat(evt.getGroupID()).map(Chat::getRecipient).map(Group.class::cast).ifPresent(evt::apply); }

View File

@ -253,15 +253,8 @@ public final class ChatScene implements EventListener, Restorable {
.ifPresent(msg -> Platform.runLater(messageList::refresh));
}
@Event
private void onUserStatusChange(UserStatusChange evt) {
chats.getSource()
.stream()
.filter(c -> c.getRecipient().getID() == evt.getID())
.findAny()
.map(Chat::getRecipient)
.ifPresent(u -> ((User) u).setStatus(evt.get()));
}
@Event(eventType = UserStatusChange.class)
private void onUserStatusChange() { Platform.runLater(chatList::refresh); }
@Event
private void onContactOperation(ContactOperation operation) {