Refactoring #55

Merged
kske merged 7 commits from refactoring into develop 2020-09-27 12:06:39 +02:00
2 changed files with 7 additions and 9 deletions
Showing only changes of commit 5daff3620e - Show all commits

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));
kske marked this conversation as resolved
Review

Did you test this? Is the normal refresh enough?

Did you test this? Is the normal refresh enough?
Review

Yes, it is, as the refresh method refreshed all objects inside the list that might have changed.

Yes, it is, as the `refresh` method refreshed all objects inside the list that might have changed.
}
@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) {