Fixed state errors in offline mode (#116)
* Display all contacts as offline while in offline mode * Update message status to sent after relaying message cache
This commit is contained in:
@ -17,6 +17,7 @@ import envoy.client.net.Client;
|
||||
import envoy.client.net.WriteProxy;
|
||||
import envoy.data.Config;
|
||||
import envoy.data.Message;
|
||||
import envoy.data.User.UserStatus;
|
||||
import envoy.exception.EnvoyException;
|
||||
import envoy.util.EnvoyLog;
|
||||
|
||||
@ -113,7 +114,7 @@ public class Startup {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"Error while loading local database: " + e + "\nChats might not be stored locally.",
|
||||
"Error while loading local database: " + e + "\nChats will not be stored locally.",
|
||||
"Local DB error",
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
@ -121,10 +122,15 @@ public class Startup {
|
||||
// Initialize write proxy
|
||||
final WriteProxy writeProxy = client.createWriteProxy(localDb);
|
||||
|
||||
// Save all users to the local database and flush cache
|
||||
if (client.isOnline()) {
|
||||
|
||||
// Save all users to the local database and flush cache
|
||||
localDb.setUsers(client.getUsers());
|
||||
writeProxy.flushCache();
|
||||
} else {
|
||||
|
||||
// Set all contacts to offline mode
|
||||
localDb.getUsers().values().stream().filter(u -> u != localDb.getUser()).forEach(u -> u.setStatus(UserStatus.OFFLINE));
|
||||
}
|
||||
|
||||
// Display ChatWindow and StatusTrayIcon
|
||||
|
Reference in New Issue
Block a user