Added deepRefresh - mechanism
additionally fixed bug not updating messageList when a MessageStatusChange occurs (seriously, why did no one notice it before?)
This commit is contained in:
@ -31,9 +31,7 @@ import envoy.client.data.audio.AudioRecorder;
|
||||
import envoy.client.event.MessageCreationEvent;
|
||||
import envoy.client.net.Client;
|
||||
import envoy.client.net.WriteProxy;
|
||||
import envoy.client.ui.IconUtil;
|
||||
import envoy.client.ui.Restorable;
|
||||
import envoy.client.ui.SceneContext;
|
||||
import envoy.client.ui.*;
|
||||
import envoy.client.ui.listcell.ChatControl;
|
||||
import envoy.client.ui.listcell.ListCellFactory;
|
||||
import envoy.client.ui.listcell.MessageControl;
|
||||
@ -144,7 +142,7 @@ public final class ChatScene implements Restorable {
|
||||
} catch (final IOException e1) {
|
||||
logger.log(Level.WARNING, "Could not read current chat: ", e1);
|
||||
}
|
||||
Platform.runLater(() -> { messageList.refresh(); scrollToMessageListEnd(); });
|
||||
Platform.runLater(() -> { ListViewRefresh.deepRefresh(messageList); scrollToMessageListEnd(); });
|
||||
} else chat.incrementUnreadAmount();
|
||||
// Moving chat with most recent unreadMessages to the top
|
||||
Platform.runLater(() -> {
|
||||
@ -158,8 +156,9 @@ public final class ChatScene implements Restorable {
|
||||
// Listen to message status changes
|
||||
eventBus.register(MessageStatusChange.class, e -> localDB.getMessage(e.getID()).ifPresent(message -> {
|
||||
message.setStatus(e.get());
|
||||
// Update UI if in current chat
|
||||
if (currentChat != null && message.getSenderID() == currentChat.getRecipient().getID()) Platform.runLater(messageList::refresh);
|
||||
// Update UI if in current chat and the current user was the sender of the
|
||||
// message
|
||||
if (currentChat != null && message.getSenderID() == client.getSender().getID()) Platform.runLater(messageList::refresh);
|
||||
}));
|
||||
|
||||
eventBus.register(GroupMessageStatusChange.class, e -> localDB.getMessage(e.getID()).ifPresent(groupMessage -> {
|
||||
@ -184,7 +183,7 @@ public final class ChatScene implements Restorable {
|
||||
switch (e.getOperationType()) {
|
||||
case ADD:
|
||||
localDB.getUsers().put(contact.getName(), contact);
|
||||
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));
|
||||
break;
|
||||
case REMOVE:
|
||||
@ -499,7 +498,7 @@ public final class ChatScene implements Restorable {
|
||||
localDB.getChats().remove(currentChat);
|
||||
localDB.getChats().add(0, currentChat);
|
||||
});
|
||||
messageList.refresh();
|
||||
ListViewRefresh.deepRefresh(messageList);
|
||||
scrollToMessageListEnd();
|
||||
|
||||
// Request a new ID generator if all IDs were used
|
||||
|
Reference in New Issue
Block a user