Readability improvements XmppPeerRepository
This commit is contained in:
parent
c165d7a633
commit
7606a3c351
|
@ -24,6 +24,9 @@ import io.reactivex.Observable;
|
|||
import io.reactivex.Scheduler;
|
||||
import io.reactivex.Single;
|
||||
import io.requery.Persistable;
|
||||
import io.requery.query.Conditional;
|
||||
import io.requery.query.Expression;
|
||||
import io.requery.query.LogicalCondition;
|
||||
import io.requery.query.ResultDelegate;
|
||||
import io.requery.reactivex.ReactiveEntityStore;
|
||||
|
||||
|
@ -139,8 +142,7 @@ public class XmppPeerRepository
|
|||
public Observable<List<Peer>> observeAllContactsOfAccount(UUID accountId) {
|
||||
return data().select(PeerModel.class)
|
||||
.where(PeerModel.ACCOUNT_ID.eq(accountId))
|
||||
.and(PeerModel.SUBSCRIPTION_DIRECTION.in(
|
||||
Arrays.asList(SubscriptionDirection.both, SubscriptionDirection.to)))
|
||||
.and(isContact())
|
||||
.get().observableResult()
|
||||
.map(ResultDelegate::toList)
|
||||
.map(peerModels -> {
|
||||
|
@ -154,6 +156,12 @@ public class XmppPeerRepository
|
|||
.observeOn(observerScheduler());
|
||||
}
|
||||
|
||||
private LogicalCondition<? extends Expression<SubscriptionDirection>, ?> isContact() {
|
||||
return PeerModel.SUBSCRIPTION_DIRECTION.in(Arrays.asList(
|
||||
SubscriptionDirection.both,
|
||||
SubscriptionDirection.to));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<Peer> updatePeer(Peer peer) {
|
||||
// In order to update, we fetch the model, update it and write it back.
|
||||
|
|
Loading…
Reference in New Issue