87 lines
3.2 KiB
Java
87 lines
3.2 KiB
Java
|
package com.discord.stores;
|
||
|
|
||
|
import com.discord.models.domain.ModelCall;
|
||
|
import com.discord.stores.updates.ObservationDeck;
|
||
|
import d0.z.d.m;
|
||
|
import java.util.HashSet;
|
||
|
import java.util.Set;
|
||
|
import rx.Observable;
|
||
|
/* compiled from: StoreCallsIncoming.kt */
|
||
|
public final class StoreCallsIncoming extends StoreV2 {
|
||
|
private final Dispatcher dispatcher;
|
||
|
private Set<Long> incomingCallSnapshot = new HashSet();
|
||
|
private final Set<Long> incomingCalls = new HashSet();
|
||
|
private final ObservationDeck observationDeck;
|
||
|
private final StoreUser userStore;
|
||
|
|
||
|
public StoreCallsIncoming(Dispatcher dispatcher, ObservationDeck observationDeck, StoreUser storeUser) {
|
||
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
||
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
||
|
m.checkNotNullParameter(storeUser, "userStore");
|
||
|
this.dispatcher = dispatcher;
|
||
|
this.observationDeck = observationDeck;
|
||
|
this.userStore = storeUser;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$clearIncomingCall(StoreCallsIncoming storeCallsIncoming, long j) {
|
||
|
storeCallsIncoming.clearIncomingCall(j);
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void clearIncomingCall(long j) {
|
||
|
if (this.incomingCalls.contains(Long.valueOf(j))) {
|
||
|
this.incomingCalls.remove(Long.valueOf(j));
|
||
|
markChanged();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final Set<Long> getIncomingCalls() {
|
||
|
return this.incomingCallSnapshot;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleCallCreateOrUpdate(ModelCall modelCall) {
|
||
|
m.checkNotNullParameter(modelCall, "call");
|
||
|
long channelId = modelCall.getChannelId();
|
||
|
if (!modelCall.getRinging().contains(Long.valueOf(this.userStore.getMe().getId()))) {
|
||
|
clearIncomingCall(channelId);
|
||
|
} else if (!this.incomingCalls.contains(Long.valueOf(channelId))) {
|
||
|
this.incomingCalls.add(Long.valueOf(channelId));
|
||
|
markChanged();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleCallDelete(ModelCall modelCall) {
|
||
|
m.checkNotNullParameter(modelCall, "callDelete");
|
||
|
clearIncomingCall(modelCall.getChannelId());
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleVoiceChannelSelected(long j) {
|
||
|
clearIncomingCall(j);
|
||
|
}
|
||
|
|
||
|
public final Observable<Boolean> observeHasIncoming() {
|
||
|
Observable<Boolean> s2 = observeIncoming().G(StoreCallsIncoming$observeHasIncoming$1.INSTANCE).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observeIncoming()\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Set<Long>> observeIncoming() {
|
||
|
Observable<Set<Long>> s2 = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreCallsIncoming$observeIncoming$1(this), 14, null).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observationDeck\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final void removeIncomingCall(long j) {
|
||
|
this.dispatcher.schedule(new StoreCallsIncoming$removeIncomingCall$1(this, j));
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.stores.StoreV2
|
||
|
public void snapshotData() {
|
||
|
super.snapshotData();
|
||
|
this.incomingCallSnapshot = new HashSet(this.incomingCalls);
|
||
|
}
|
||
|
}
|