Commit 0a694b50 authored by Yusuke Iwaki's avatar Yusuke Iwaki

fix login is called many times.

parent e387dbcf
...@@ -55,7 +55,7 @@ public class GitHubOAuthFragment extends AbstractWebViewFragment { ...@@ -55,7 +55,7 @@ public class GitHubOAuthFragment extends AbstractWebViewFragment {
MeteorLoginServiceConfiguration oauthConfig = RealmHelper.executeTransactionForRead(realm -> MeteorLoginServiceConfiguration oauthConfig = RealmHelper.executeTransactionForRead(realm ->
realm.where(MeteorLoginServiceConfiguration.class) realm.where(MeteorLoginServiceConfiguration.class)
.equalTo("service", "github") .equalTo("service", "github")
.equalTo("serverConfig.id", serverConfigId) .equalTo("serverConfigId", serverConfigId)
.findFirst()); .findFirst());
if (serverConfig == null || oauthConfig == null) { if (serverConfig == null || oauthConfig == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
......
...@@ -25,7 +25,7 @@ public class LoginFragment extends AbstractServerConfigFragment { ...@@ -25,7 +25,7 @@ public class LoginFragment extends AbstractServerConfigFragment {
new RealmListObserver<MeteorLoginServiceConfiguration>() { new RealmListObserver<MeteorLoginServiceConfiguration>() {
@Override protected RealmResults<MeteorLoginServiceConfiguration> queryItems(Realm realm) { @Override protected RealmResults<MeteorLoginServiceConfiguration> queryItems(Realm realm) {
return realm.where(MeteorLoginServiceConfiguration.class) return realm.where(MeteorLoginServiceConfiguration.class)
.equalTo("serverConfig.id", serverConfigId) .equalTo("serverConfigId", serverConfigId)
.findAll(); .findAll();
} }
......
...@@ -10,7 +10,7 @@ import io.realm.annotations.PrimaryKey; ...@@ -10,7 +10,7 @@ import io.realm.annotations.PrimaryKey;
public class MeteorLoginServiceConfiguration public class MeteorLoginServiceConfiguration
extends RealmObject { extends RealmObject {
@PrimaryKey private String id; @PrimaryKey private String id;
private ServerConfig serverConfig; private String serverConfigId;
private String service; private String service;
private String consumerKey; //for Twitter private String consumerKey; //for Twitter
private String appId; //for Facebook private String appId; //for Facebook
...@@ -24,12 +24,12 @@ public class MeteorLoginServiceConfiguration ...@@ -24,12 +24,12 @@ public class MeteorLoginServiceConfiguration
this.id = id; this.id = id;
} }
public ServerConfig getServerConfig() { public String getServerConfigId() {
return serverConfig; return serverConfigId;
} }
public void setServerConfig(ServerConfig serverConfig) { public void setServerConfigId(String serverConfigId) {
this.serverConfig = serverConfig; this.serverConfigId = serverConfigId;
} }
public String getService() { public String getService() {
......
...@@ -93,7 +93,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable { ...@@ -93,7 +93,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
private void onDocumentAdded(Realm realm, DDPSubscription.Added docEvent) throws JSONException { private void onDocumentAdded(Realm realm, DDPSubscription.Added docEvent) throws JSONException {
//executed in RealmTransaction //executed in RealmTransaction
JSONObject json = new JSONObject().put("id", docEvent.docID); JSONObject json = new JSONObject().put("id", docEvent.docID);
json.put("serverConfig", new JSONObject().put("id", serverConfigId)); json.put("serverConfigId", serverConfigId);
mergeJson(json, docEvent.fields); mergeJson(json, docEvent.fields);
realm.createOrUpdateObjectFromJson(getModelClass(), customizeFieldJson(json)); realm.createOrUpdateObjectFromJson(getModelClass(), customizeFieldJson(json));
} }
...@@ -109,7 +109,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable { ...@@ -109,7 +109,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
throws JSONException { throws JSONException {
//executed in RealmTransaction //executed in RealmTransaction
JSONObject json = new JSONObject().put("id", docEvent.docID); JSONObject json = new JSONObject().put("id", docEvent.docID);
json.put("serverConfig", new JSONObject().put("id", serverConfigId)); json.put("serverConfigId", serverConfigId);
for (int i = 0; i < docEvent.cleared.length(); i++) { for (int i = 0; i < docEvent.cleared.length(); i++) {
String fieldToDelete = docEvent.cleared.getString(i); String fieldToDelete = docEvent.cleared.getString(i);
json.put(fieldToDelete, JSONObject.NULL); json.put(fieldToDelete, JSONObject.NULL);
......
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