Renamed database package to data, moved Chat to data package

This commit is contained in:
2020-02-05 20:58:30 +01:00
parent d005ed8d50
commit 81dcee27f1
7 changed files with 23 additions and 27 deletions

View File

@ -10,9 +10,9 @@ import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import envoy.client.Chat;
import envoy.client.Settings;
import envoy.client.database.LocalDb;
import envoy.client.data.Chat;
import envoy.client.data.LocalDb;
import envoy.client.event.MessageCreationEvent;
import envoy.client.event.ThemeChangeEvent;
import envoy.client.net.Client;
@ -175,13 +175,8 @@ public class ChatWindow extends JFrame {
// Select current chat
currentChat = localDb.getChats().stream().filter(chat -> chat.getRecipient().getId() == user.getId()).findFirst().get();
// Read current Chat
try {
currentChat.read(client);
} catch (IOException e) {
e.printStackTrace();
logger.log(Level.WARNING, "Could notify server about message status change", e);
}
// Read current chat
readCurrentChat();
// Set chat title
textPane.setText(currentChat.getRecipient().getName());
@ -221,15 +216,7 @@ public class ChatWindow extends JFrame {
chat.appendMessage(message);
// Read message and update UI if in current chat
if (chat == currentChat) {
try {
currentChat.read(client);
} catch (IOException e) {
e.printStackTrace();
logger.log(Level.WARNING, "Could notify server about message status change", e);
}
messageList.synchronizeModel();
}
if (chat == currentChat) readCurrentChat();
revalidate();
repaint();
@ -356,6 +343,16 @@ public class ChatWindow extends JFrame {
}).start();
}
private void readCurrentChat() {
try {
currentChat.read(client);
messageList.synchronizeModel();
} catch (IOException e) {
e.printStackTrace();
logger.log(Level.WARNING, "Couldn't notify server about message status change", e);
}
}
/**
* Sets the {@link Client} used by this {@link ChatWindow}.
*