Add Ability to Change the User Status Freely #90

Merged
delvh merged 7 commits from f/change-user-status into develop 2020-10-10 14:16:29 +02:00
Showing only changes of commit fa2a5d0b24 - Show all commits

View File

@ -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()