Commit 00c1d279 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Add null checks

parent 3aeddf34
......@@ -84,6 +84,9 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
return Flowable.defer(() -> Flowable.using(
() -> new Pair<>(RealmStore.getRealm(hostname), Looper.myLooper()),
pair -> {
if (pair.first == null) {
return Flowable.empty();
}
LoadMessageProcedure messageProcedure = pair.first.where(LoadMessageProcedure.class)
.equalTo(LoadMessageProcedure.ID, roomId)
......
......@@ -60,11 +60,16 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
private Flowable<RealmResults<RealmUser>> realmGetCurrent() {
return Flowable.using(
() -> new Pair<>(RealmStore.getRealm(hostname), Looper.myLooper()),
pair -> RxJavaInterop.toV2Flowable(
pair -> {
if (pair.first == null) {
return Flowable.empty();
}
return RxJavaInterop.toV2Flowable(
pair.first.where(RealmUser.class)
.isNotEmpty(RealmUser.EMAILS)
.findAll()
.<RealmResults<RealmUser>>asObservable()),
.<RealmResults<RealmUser>>asObservable());
},
pair -> close(pair.first, pair.second));
}
......
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