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
|
// Move chat with most recent unread messages to the top
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
chatList.getItems().remove(chat);
|
chats.getSource().remove(chat);
|
||||||
chatList.getItems().add(0, chat);
|
((ObservableList<Chat>) chats.getSource()).add(0, chat);
|
||||||
|
|
||||||
if (chat.equals(currentChat)) chatList.getSelectionModel().select(0);
|
if (chat.equals(currentChat)) chatList.getSelectionModel().select(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -215,7 +216,7 @@ public final class ChatScene implements Restorable {
|
|||||||
|
|
||||||
// Listen to user status changes
|
// Listen to user status changes
|
||||||
eventBus.register(UserStatusChange.class,
|
eventBus.register(UserStatusChange.class,
|
||||||
e -> chatList.getItems()
|
e -> chats.getSource()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(c -> c.getRecipient().getID() == e.getID())
|
.filter(c -> c.getRecipient().getID() == e.getID())
|
||||||
.findAny()
|
.findAny()
|
||||||
@ -229,10 +230,11 @@ public final class ChatScene implements Restorable {
|
|||||||
case ADD:
|
case ADD:
|
||||||
if (contact instanceof User) localDB.getUsers().put(contact.getName(), (User) contact);
|
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);
|
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;
|
break;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
Platform.runLater(() -> chatList.getItems().removeIf(c -> c.getRecipient().equals(contact)));
|
Platform.runLater(() -> chats.getSource().removeIf(c -> c.getRecipient().equals(contact)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user