Extracted updateUserStates method, fixed localDB initialization

This commit is contained in:
Kai S. K. Engelbart 2019-11-09 09:38:10 +01:00
parent ba0c588c77
commit 67f9f5133f
2 changed files with 9 additions and 10 deletions

View File

@ -53,6 +53,7 @@ public class Config {
case "-db":
localDB = new File(args[++i]);
}
if (localDB == null) localDB = new File(".\\localDB");
}
/**

View File

@ -275,19 +275,17 @@ public class ChatWindow extends JFrame {
client.addUnreadMessagesToLocalDB(localDB);
client.clearUnreadMessagesSync();
for (int i = 0; i < userList.getModel().getSize(); i++) {
for (int j = 0; j < localDB.getChats().size(); j++) {
if(userList.getModel().getElementAt(i).getID() == localDB.getChats().get(j).getRecipient().getID()) {
userList.getModel().getElementAt(i).setStatus(localDB.getChats().get(j).getRecipient().getStatus());
}
}
}
updateUserStates();
contentPane.revalidate();
contentPane.repaint();
userList.revalidate();
userList.repaint();
}).start();
}
private void updateUserStates() {
for (int i = 0; i < userList.getModel().getSize(); i++)
for (int j = 0; j < localDB.getChats().size(); j++)
if (userList.getModel().getElementAt(i).getID() == localDB.getChats().get(j).getRecipient().getID())
userList.getModel().getElementAt(i).setStatus(localDB.getChats().get(j).getRecipient().getStatus());
}
}