Extracted updateUserStates method, fixed localDB initialization

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

View File

@ -53,6 +53,7 @@ public class Config {
case "-db": case "-db":
localDB = new File(args[++i]); 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.addUnreadMessagesToLocalDB(localDB);
client.clearUnreadMessagesSync(); client.clearUnreadMessagesSync();
for (int i = 0; i < userList.getModel().getSize(); i++) { updateUserStates();
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());
}
}
}
contentPane.revalidate(); contentPane.revalidate();
contentPane.repaint(); contentPane.repaint();
userList.revalidate();
userList.repaint();
}).start(); }).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());
}
} }