60 lines
2.2 KiB
Java
60 lines
2.2 KiB
Java
package com.discord.stores;
|
|
|
|
import com.discord.stores.StoreRtcConnection;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import d0.z.d.m;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import rx.Observable;
|
|
/* compiled from: StoreVoiceSpeaking.kt */
|
|
public final class StoreVoiceSpeaking extends StoreV2 {
|
|
private final ObservationDeck observationDeck;
|
|
private final HashSet<Long> speakingUsers = new HashSet<>();
|
|
private Set<Long> speakingUsersSnapshot = new HashSet();
|
|
|
|
public StoreVoiceSpeaking(ObservationDeck observationDeck) {
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
this.observationDeck = observationDeck;
|
|
}
|
|
|
|
public final Set<Long> getSpeakingUsers() {
|
|
return this.speakingUsersSnapshot;
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleSpeakingUpdates(List<StoreRtcConnection.SpeakingUserUpdate> list) {
|
|
m.checkNotNullParameter(list, "speakingList");
|
|
boolean z2 = false;
|
|
for (StoreRtcConnection.SpeakingUserUpdate speakingUserUpdate : list) {
|
|
long component1 = speakingUserUpdate.component1();
|
|
boolean add = speakingUserUpdate.component2() ? this.speakingUsers.add(Long.valueOf(component1)) : this.speakingUsers.remove(Long.valueOf(component1));
|
|
if (!z2 && add) {
|
|
z2 = true;
|
|
}
|
|
}
|
|
if (z2) {
|
|
markChanged();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleVoiceChannelSelected(long j) {
|
|
if (!(j > 0)) {
|
|
this.speakingUsers.clear();
|
|
markChanged();
|
|
}
|
|
}
|
|
|
|
public final Observable<Set<Long>> observeSpeakingUsers() {
|
|
Observable<Set<Long>> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreVoiceSpeaking$observeSpeakingUsers$1(this), 14, null).r();
|
|
m.checkNotNullExpressionValue(r, "observationDeck\n … .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
public void snapshotData() {
|
|
super.snapshotData();
|
|
this.speakingUsersSnapshot = new HashSet(this.speakingUsers);
|
|
}
|
|
}
|