Commit f6fb3f61 authored by Yusuke Iwaki's avatar Yusuke Iwaki

fix connection error handling on token login.

parent d8f0d912
......@@ -15,6 +15,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
/**
* Background service for Rocket.Chat.Application class.
......@@ -59,7 +60,19 @@ public class RocketChatService extends Service {
}
@Override public int onStartCommand(Intent intent, int flags, int startId) {
connectionRequiredServerConfigObserver.keepalive();
RealmHelperBolts.executeTransaction(realm -> {
RealmResults<ServerConfig> targetConfigs = realm.where(ServerConfig.class)
.isNotNull("token")
.isNotNull("connectionError")
.findAll();
for (ServerConfig config : targetConfigs) {
config.setConnectionError(null);
}
return null;
}).onSuccessTask(task -> {
connectionRequiredServerConfigObserver.keepalive();
return null;
});
return START_STICKY;
}
......
......@@ -17,6 +17,7 @@ public class TokenLoginObserver extends AbstractModelObserver<ServerConfig> {
@Override protected RealmResults<ServerConfig> queryItems(Realm realm) {
return realm.where(ServerConfig.class)
.isNotNull("session")
.isNotNull("token")
.equalTo("tokenVerified", false)
.findAll();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment