Add Ability to Change the User Status Freely #90
@ -113,9 +113,13 @@ public final class Startup extends Application {
|
||||
cacheMap.put(GroupMessage.class, new Cache<GroupMessage>());
|
||||
cacheMap.put(MessageStatusChange.class, new Cache<MessageStatusChange>());
|
||||
cacheMap.put(GroupMessageStatusChange.class, new Cache<GroupMessageStatusChange>());
|
||||
final var originalStatus = localDB.getUser().getStatus();
|
||||
try {
|
||||
client.performHandshake(credentials, cacheMap);
|
||||
if (client.isOnline()) {
|
||||
|
||||
// Restore the original status as the server automatically returns status ONLINE
|
||||
client.getSender().setStatus(originalStatus);
|
||||
loadChatScene();
|
||||
client.initReceiver(localDB, cacheMap);
|
||||
return true;
|
||||
@ -170,7 +174,8 @@ public final class Startup extends Application {
|
||||
private static void loadChatScene() {
|
||||
|
||||
// Set client user in local database
|
||||
localDB.setUser(client.getSender());
|
||||
final var user = client.getSender();
|
||||
localDB.setUser(user);
|
||||
|
||||
// Initialize chats in local database
|
||||
try {
|
||||
@ -184,8 +189,13 @@ public final class Startup extends Application {
|
||||
|
||||
context.initWriteProxy();
|
||||
|
||||
if (client.isOnline()) context.getWriteProxy().flushCache();
|
||||
else
|
||||
if (client.isOnline()) {
|
||||
context.getWriteProxy().flushCache();
|
||||
|
||||
// Inform the server that this user has a different user status than expected
|
||||
if (!user.getStatus().equals(UserStatus.ONLINE)) client.send(new UserStatusChange(user));
|
||||
} else
|
||||
|
||||
// Set all contacts to offline mode
|
||||
localDB.getChats()
|
||||
.stream()
|
||||
|
Reference in New Issue
Block a user