Fixed threading issue when receiving unread messages
This commit is contained in:
@ -106,11 +106,11 @@ public class Startup {
|
||||
// Acquire the client user (with ID) either from the server or from the local
|
||||
// database, which triggers offline mode
|
||||
Client client = new Client();
|
||||
Cache<Message> cache = null;
|
||||
Cache<Message> cache = new Cache<>();
|
||||
try {
|
||||
// Try entering online mode first
|
||||
localDb.loadIdGenerator();
|
||||
cache = client.onlineInit(credentials, localDb);
|
||||
client.onlineInit(credentials, localDb, cache);
|
||||
} catch (Exception e1) {
|
||||
logger.warning("Could not connect to server. Trying offline mode...");
|
||||
e1.printStackTrace();
|
||||
@ -162,6 +162,9 @@ public class Startup {
|
||||
try {
|
||||
chatWindow.initContent(client, localDb, writeProxy);
|
||||
|
||||
// Relay unread messages from cache
|
||||
if (cache != null) cache.relay();
|
||||
|
||||
try {
|
||||
new StatusTrayIcon(chatWindow).show();
|
||||
|
||||
@ -180,9 +183,6 @@ public class Startup {
|
||||
}
|
||||
});
|
||||
|
||||
// Relay unread messages from cache
|
||||
if (cache != null) cache.relay();
|
||||
|
||||
// Save Settings and PersistentLocalDb on shutdown
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user