Commit 6d4ef307 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #404 from RocketChat/fix/messages-history-ramdonly-missing

Fixes message history randomly missing from room
parents bb01f6a6 e4c6378c
......@@ -3,6 +3,9 @@ apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
}
apply plugin: 'kotlin-android'
......@@ -44,7 +47,7 @@ android {
applicationId "chat.rocket.android"
minSdkVersion 16
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 29
versionCode 30
versionName "1.0.16"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
......@@ -123,7 +126,7 @@ dependencies {
compile "com.facebook.stetho:stetho:$stethoVersion"
compile "com.facebook.stetho:stetho-okhttp3:$stethoVersion"
compile 'com.uphyca:stetho_realm:2.0.1'
compile 'com.uphyca:stetho_realm:2.1.0'
compile "com.jakewharton.rxbinding2:rxbinding:$rxbindingVersion"
compile "com.jakewharton.rxbinding2:rxbinding-support-v4:$rxbindingVersion"
......
......@@ -2,6 +2,8 @@ package chat.rocket.android.service.ddp;
import android.content.Context;
import android.text.TextUtils;
import chat.rocket.persistence.realm.models.ddp.RealmUser;
import io.reactivex.disposables.Disposable;
import io.realm.Realm;
import io.realm.RealmObject;
......@@ -16,6 +18,7 @@ import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.android.service.DDPClientRef;
import chat.rocket.android.service.Registrable;
import chat.rocket.android_ddp.DDPSubscription;
import io.realm.RealmResults;
public abstract class AbstractDDPDocEventSubscriber implements Registrable {
protected final Context context;
......@@ -167,7 +170,16 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable {
private void onDocumentRemoved(Realm realm, DDPSubscription.Removed docEvent)
throws JSONException {
//executed in RealmTransaction
realm.where(getModelClass()).equalTo("_id", docEvent.docID).findAll().deleteAllFromRealm();
RealmResults<? extends RealmObject> docs = realm.where(getModelClass())
.equalTo("_id", docEvent.docID).findAll();
if (RealmUser.class.equals(getModelClass())) {
for (RealmObject doc : docs) {
RealmUser user = (RealmUser) doc;
user.setStatus(RealmUser.STATUS_OFFLINE);
}
} else {
docs.deleteAllFromRealm();
}
}
private void mergeJson(JSONObject target, JSONObject src) throws JSONException {
......
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