Fixed errors caused by the new ListModel
This commit is contained in:
parent
60dd4b6152
commit
1cf6b98523
@ -191,8 +191,9 @@ public final class ChatScene implements Restorable {
|
||||
|
||||
// Move chat with most recent unread messages to the top
|
||||
Platform.runLater(() -> {
|
||||
chatList.getItems().remove(chat);
|
||||
chatList.getItems().add(0, chat);
|
||||
chats.getSource().remove(chat);
|
||||
((ObservableList<Chat>) chats.getSource()).add(0, chat);
|
||||
|
||||
if (chat.equals(currentChat)) chatList.getSelectionModel().select(0);
|
||||
});
|
||||
});
|
||||
@ -215,7 +216,7 @@ public final class ChatScene implements Restorable {
|
||||
|
||||
// Listen to user status changes
|
||||
eventBus.register(UserStatusChange.class,
|
||||
e -> chatList.getItems()
|
||||
e -> chats.getSource()
|
||||
.stream()
|
||||
.filter(c -> c.getRecipient().getID() == e.getID())
|
||||
.findAny()
|
||||
@ -229,10 +230,11 @@ public final class ChatScene implements Restorable {
|
||||
case ADD:
|
||||
if (contact instanceof User) localDB.getUsers().put(contact.getName(), (User) contact);
|
||||
final Chat chat = contact instanceof User ? new Chat(contact) : new GroupChat(client.getSender(), contact);
|
||||
Platform.runLater(() -> chatList.getItems().add(chat));
|
||||
Platform.runLater(() -> ((ObservableList<Chat>) chats.getSource()).add(0, chat));
|
||||
|
||||
break;
|
||||
case REMOVE:
|
||||
Platform.runLater(() -> chatList.getItems().removeIf(c -> c.getRecipient().equals(contact)));
|
||||
Platform.runLater(() -> chats.getSource().removeIf(c -> c.getRecipient().equals(contact)));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user