Wrapping data into ObservableList instances instead of copying it
This commit is contained in:
parent
dbf944b5cb
commit
94dbf0481b
@ -95,7 +95,7 @@ public final class ChatSceneController {
|
|||||||
this.writeProxy = writeProxy;
|
this.writeProxy = writeProxy;
|
||||||
|
|
||||||
// TODO: handle offline mode
|
// TODO: handle offline mode
|
||||||
userList.getItems().addAll(client.getContacts().getContacts());
|
userList.setItems(FXCollections.observableList(client.getContacts().getContacts()));
|
||||||
// userList.getItems().addAll(localDB.getChats().stream().map(Chat::getRecipient).collect(Collectors.toList()));
|
// userList.getItems().addAll(localDB.getChats().stream().map(Chat::getRecipient).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,12 +105,6 @@ public final class ChatSceneController {
|
|||||||
if (user != null && (currentChat == null || user.getID() != currentChat.getRecipient().getID())) {
|
if (user != null && (currentChat == null || user.getID() != currentChat.getRecipient().getID())) {
|
||||||
contactLabel.setText(user.getName());
|
contactLabel.setText(user.getName());
|
||||||
|
|
||||||
// Swap observable list
|
|
||||||
if (currentChat != null) {
|
|
||||||
currentChat.getMessages().clear();
|
|
||||||
currentChat.getMessages().addAll(messageList.getItems());
|
|
||||||
}
|
|
||||||
|
|
||||||
// LEON: JFC <===> JAVA FRIED CHICKEN <=/=> Java Foundation Classes
|
// LEON: JFC <===> JAVA FRIED CHICKEN <=/=> Java Foundation Classes
|
||||||
|
|
||||||
// Load the chat or create a new one and add it to the LocalDB
|
// Load the chat or create a new one and add it to the LocalDB
|
||||||
@ -119,7 +113,8 @@ public final class ChatSceneController {
|
|||||||
.filter(c -> c.getRecipient().getID() == user.getID())
|
.filter(c -> c.getRecipient().getID() == user.getID())
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElseGet(() -> { var chat = new Chat(user); localDB.getChats().add(chat); return chat; });
|
.orElseGet(() -> { var chat = new Chat(user); localDB.getChats().add(chat); return chat; });
|
||||||
messageList.setItems(FXCollections.observableArrayList(currentChat.getMessages()));
|
|
||||||
|
messageList.setItems(FXCollections.observableList(currentChat.getMessages()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ module envoy {
|
|||||||
requires transitive java.prefs;
|
requires transitive java.prefs;
|
||||||
requires javafx.controls;
|
requires javafx.controls;
|
||||||
requires javafx.fxml;
|
requires javafx.fxml;
|
||||||
|
requires javafx.base;
|
||||||
|
|
||||||
opens envoy.client.ui to javafx.graphics, javafx.fxml;
|
opens envoy.client.ui to javafx.graphics, javafx.fxml;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user