parent
f02b01291b
commit
0c10068fb5
@ -222,20 +222,21 @@ public final class ChatScene implements EventListener, Restorable {
|
||||
// The sender of the message is the recipient of the chat
|
||||
// Exceptions: this user is the sender (sync) or group message (group is
|
||||
// recipient)
|
||||
final var recipientID = message instanceof GroupMessage || message.getSenderID() == localDB.getUser().getID() ? message.getRecipientID()
|
||||
: message.getSenderID();
|
||||
final boolean ownMessage = message.getSenderID() == localDB.getUser().getID();
|
||||
final var recipientID = message instanceof GroupMessage || ownMessage ? message.getRecipientID() : message.getSenderID();
|
||||
|
||||
localDB.getChat(recipientID).ifPresent(chat -> {
|
||||
chat.insert(message);
|
||||
|
||||
// Read current chat or increment unread amount
|
||||
if (chat.equals(currentChat)) {
|
||||
try {
|
||||
currentChat.read(writeProxy);
|
||||
} catch (final IOException e1) {
|
||||
logger.log(Level.WARNING, "Could not read current chat: ", e1);
|
||||
} catch (final IOException e) {
|
||||
logger.log(Level.WARNING, "Could not read current chat: ", e);
|
||||
}
|
||||
Platform.runLater(() -> { ListViewRefresh.deepRefresh(messageList); scrollToMessageListEnd(); });
|
||||
// TODO: Increment unread counter for group messages with status < RECEIVED
|
||||
} else
|
||||
if (message.getSenderID() != localDB.getUser().getID() && message.getStatus() == MessageStatus.RECEIVED) chat.incrementUnreadAmount();
|
||||
} else if (!ownMessage && message.getStatus() != MessageStatus.READ) chat.incrementUnreadAmount();
|
||||
|
||||
// Move chat with most recent unread messages to the top
|
||||
Platform.runLater(() -> {
|
||||
|
Reference in New Issue
Block a user