Merge branch 'develop' into f/logging
This commit is contained in:
@ -226,7 +226,7 @@ public class ChatWindow extends JFrame {
|
||||
.get();
|
||||
|
||||
// Set all unread messages in the chat to read
|
||||
if (currentChat != null) { localDB.setMessagesToRead(currentChat); }
|
||||
readCurrentChat();
|
||||
|
||||
client.setRecipient(user);
|
||||
|
||||
@ -272,7 +272,7 @@ public class ChatWindow extends JFrame {
|
||||
|
||||
// Create and send message object
|
||||
final Message message = localDB.createMessage(messageEnterTextArea.getText(), currentChat.getRecipient());
|
||||
localDB.addWaitingMessageToLocalDB(message, currentChat);
|
||||
currentChat.appendMessage(message);
|
||||
messageList.setModel(currentChat.getModel());
|
||||
|
||||
// Clear text field
|
||||
@ -309,7 +309,8 @@ public class ChatWindow extends JFrame {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the data model and the ui every x seconds.
|
||||
* Updates the data model and the UI repeatedly after a certain amount of
|
||||
* time.
|
||||
*
|
||||
* @param timeout the amount of time that passes between two requests sent to
|
||||
* the server
|
||||
@ -322,9 +323,14 @@ public class ChatWindow extends JFrame {
|
||||
// Synchronize
|
||||
localDB.applySync(
|
||||
client.sendSync(client.getSender().getID(), localDB.fillSync(client.getSender().getID())));
|
||||
|
||||
// Process unread messages
|
||||
localDB.addUnreadMessagesToLocalDB();
|
||||
localDB.clearUnreadMessagesSync();
|
||||
|
||||
// Mark unread messages as read when they are in the current chat
|
||||
readCurrentChat();
|
||||
|
||||
// Update UI
|
||||
SwingUtilities
|
||||
.invokeLater(() -> { updateUserStates(); contentPane.revalidate(); contentPane.repaint(); });
|
||||
@ -338,4 +344,9 @@ public class ChatWindow extends JFrame {
|
||||
if (userList.getModel().getElementAt(i).getID() == localDB.getChats().get(j).getRecipient().getID())
|
||||
userList.getModel().getElementAt(i).setStatus(localDB.getChats().get(j).getRecipient().getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks messages in the current chat as {@code READ}.
|
||||
*/
|
||||
private void readCurrentChat() { if (currentChat != null) { localDB.setMessagesToRead(currentChat); } }
|
||||
}
|
||||
|
Reference in New Issue
Block a user