discord-jadx/app/src/main/java/com/discord/stores/StoreVoiceParticipants.java

489 lines
23 KiB
Java

package com.discord.stores;
import android.content.Context;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
import com.discord.api.voice.state.StageRequestToSpeakState;
import com.discord.api.voice.state.VoiceState;
import com.discord.models.domain.ModelApplicationStream;
import com.discord.models.member.GuildMember;
import com.discord.models.user.MeUser;
import com.discord.models.user.User;
import com.discord.stores.StoreMediaSettings;
import com.discord.stores.StoreVideoStreams;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.streams.StreamContext;
import com.discord.utilities.streams.StreamContextService;
import d0.t.n;
import d0.t.o;
import d0.t.u;
import d0.z.d.m;
import j0.l.e.j;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import rx.Observable;
import rx.subjects.BehaviorSubject;
/* compiled from: StoreVoiceParticipants.kt */
public final class StoreVoiceParticipants extends Store {
private final BehaviorSubject<Long> selectedParticipantSubject = BehaviorSubject.l0(0L);
private final StoreStream stream;
/* compiled from: StoreVoiceParticipants.kt */
public static final class VoiceUser {
private final boolean _isSpeaking;
private final ModelApplicationStream applicationStream;
private final Integer applicationStreamId;
private final Integer callStreamId;
private final GuildMember guildMember;
private final boolean isBooster;
private final boolean isDeafened;
private final boolean isInvitedToSpeak;
private final boolean isMe;
private final boolean isMuted;
private final boolean isRequestingToSpeak;
private final boolean isRinging;
private final boolean isSelfDeafened;
private final boolean isSelfMuted;
private final boolean isServerDeafened;
private final boolean isServerMuted;
private final boolean isSpeaking;
private final String nickname;
private final StreamContext streamContext;
private final StoreVideoStreams.UserStreams streams;
private final User user;
private final StoreMediaSettings.VoiceConfiguration voiceConfiguration;
private final VoiceState voiceState;
private final String watchingStream;
/* JADX WARNING: Removed duplicated region for block: B:37:0x007c A[ADDED_TO_REGION] */
/* JADX WARNING: Removed duplicated region for block: B:42:0x0086 */
/* JADX WARNING: Removed duplicated region for block: B:43:0x008b */
/* JADX WARNING: Removed duplicated region for block: B:46:0x0090 */
/* JADX WARNING: Removed duplicated region for block: B:48:0x0097 */
/* JADX WARNING: Removed duplicated region for block: B:53:0x00a3 A[ADDED_TO_REGION] */
/* JADX WARNING: Removed duplicated region for block: B:58:0x00be */
public VoiceUser(User user, VoiceState voiceState, boolean z2, StoreVideoStreams.UserStreams userStreams, boolean z3, GuildMember guildMember, String str, StreamContext streamContext, boolean z4, StoreMediaSettings.VoiceConfiguration voiceConfiguration, boolean z5) {
boolean z6;
boolean z7;
m.checkNotNullParameter(user, "user");
this.user = user;
this.voiceState = voiceState;
this.isRinging = z2;
this.streams = userStreams;
this.isMe = z3;
this.guildMember = guildMember;
this.watchingStream = str;
this.streamContext = streamContext;
this.isBooster = z4;
this.voiceConfiguration = voiceConfiguration;
this._isSpeaking = z5;
boolean z8 = true;
this.isSpeaking = voiceState != null && z5 && !voiceState.e() && !voiceState.b();
ModelApplicationStream modelApplicationStream = null;
this.nickname = guildMember != null ? guildMember.getNick() : null;
this.callStreamId = userStreams != null ? userStreams.getCallStreamId() : null;
this.applicationStreamId = userStreams != null ? userStreams.getApplicationStreamId() : null;
this.applicationStream = streamContext != null ? streamContext.getStream() : modelApplicationStream;
boolean e = voiceState != null ? voiceState.e() : false;
this.isServerMuted = e;
if (z3) {
if (voiceConfiguration != null) {
z6 = voiceConfiguration.isSelfMuted();
this.isSelfMuted = z6;
this.isMuted = !e || z6;
boolean b = voiceState != null ? voiceState.b() : false;
this.isServerDeafened = b;
if (z3) {
if (voiceConfiguration != null) {
z7 = voiceConfiguration.isSelfDeafened();
this.isSelfDeafened = z7;
this.isDeafened = !b || z7;
this.isRequestingToSpeak = AnimatableValueParser.H0(voiceState).isRequestingToSpeak();
this.isInvitedToSpeak = AnimatableValueParser.H0(voiceState) != StageRequestToSpeakState.REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK ? false : z8;
}
} else if (voiceState != null) {
z7 = voiceState.g();
this.isSelfDeafened = z7;
this.isDeafened = !b || z7;
this.isRequestingToSpeak = AnimatableValueParser.H0(voiceState).isRequestingToSpeak();
this.isInvitedToSpeak = AnimatableValueParser.H0(voiceState) != StageRequestToSpeakState.REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK ? false : z8;
}
z7 = false;
this.isSelfDeafened = z7;
this.isDeafened = !b || z7;
this.isRequestingToSpeak = AnimatableValueParser.H0(voiceState).isRequestingToSpeak();
this.isInvitedToSpeak = AnimatableValueParser.H0(voiceState) != StageRequestToSpeakState.REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK ? false : z8;
}
} else if (voiceState != null) {
z6 = voiceState.h();
this.isSelfMuted = z6;
this.isMuted = !e || z6;
if (voiceState != null) {
}
this.isServerDeafened = b;
if (z3) {
}
z7 = false;
this.isSelfDeafened = z7;
this.isDeafened = !b || z7;
this.isRequestingToSpeak = AnimatableValueParser.H0(voiceState).isRequestingToSpeak();
this.isInvitedToSpeak = AnimatableValueParser.H0(voiceState) != StageRequestToSpeakState.REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK ? false : z8;
}
z6 = false;
this.isSelfMuted = z6;
this.isMuted = !e || z6;
if (voiceState != null) {
}
this.isServerDeafened = b;
if (z3) {
}
z7 = false;
this.isSelfDeafened = z7;
this.isDeafened = !b || z7;
this.isRequestingToSpeak = AnimatableValueParser.H0(voiceState).isRequestingToSpeak();
this.isInvitedToSpeak = AnimatableValueParser.H0(voiceState) != StageRequestToSpeakState.REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK ? false : z8;
}
private final StoreMediaSettings.VoiceConfiguration component10() {
return this.voiceConfiguration;
}
private final boolean component11() {
return this._isSpeaking;
}
public static /* synthetic */ VoiceUser copy$default(VoiceUser voiceUser, User user, VoiceState voiceState, boolean z2, StoreVideoStreams.UserStreams userStreams, boolean z3, GuildMember guildMember, String str, StreamContext streamContext, boolean z4, StoreMediaSettings.VoiceConfiguration voiceConfiguration, boolean z5, int i, Object obj) {
return voiceUser.copy((i & 1) != 0 ? voiceUser.user : user, (i & 2) != 0 ? voiceUser.voiceState : voiceState, (i & 4) != 0 ? voiceUser.isRinging : z2, (i & 8) != 0 ? voiceUser.streams : userStreams, (i & 16) != 0 ? voiceUser.isMe : z3, (i & 32) != 0 ? voiceUser.guildMember : guildMember, (i & 64) != 0 ? voiceUser.watchingStream : str, (i & 128) != 0 ? voiceUser.streamContext : streamContext, (i & 256) != 0 ? voiceUser.isBooster : z4, (i & 512) != 0 ? voiceUser.voiceConfiguration : voiceConfiguration, (i & 1024) != 0 ? voiceUser._isSpeaking : z5);
}
public final User component1() {
return this.user;
}
public final VoiceState component2() {
return this.voiceState;
}
public final boolean component3() {
return this.isRinging;
}
public final StoreVideoStreams.UserStreams component4() {
return this.streams;
}
public final boolean component5() {
return this.isMe;
}
public final GuildMember component6() {
return this.guildMember;
}
public final String component7() {
return this.watchingStream;
}
public final StreamContext component8() {
return this.streamContext;
}
public final boolean component9() {
return this.isBooster;
}
public final VoiceUser copy(User user, VoiceState voiceState, boolean z2, StoreVideoStreams.UserStreams userStreams, boolean z3, GuildMember guildMember, String str, StreamContext streamContext, boolean z4, StoreMediaSettings.VoiceConfiguration voiceConfiguration, boolean z5) {
m.checkNotNullParameter(user, "user");
return new VoiceUser(user, voiceState, z2, userStreams, z3, guildMember, str, streamContext, z4, voiceConfiguration, z5);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof VoiceUser)) {
return false;
}
VoiceUser voiceUser = (VoiceUser) obj;
return m.areEqual(this.user, voiceUser.user) && m.areEqual(this.voiceState, voiceUser.voiceState) && this.isRinging == voiceUser.isRinging && m.areEqual(this.streams, voiceUser.streams) && this.isMe == voiceUser.isMe && m.areEqual(this.guildMember, voiceUser.guildMember) && m.areEqual(this.watchingStream, voiceUser.watchingStream) && m.areEqual(this.streamContext, voiceUser.streamContext) && this.isBooster == voiceUser.isBooster && m.areEqual(this.voiceConfiguration, voiceUser.voiceConfiguration) && this._isSpeaking == voiceUser._isSpeaking;
}
public final ModelApplicationStream getApplicationStream() {
return this.applicationStream;
}
public final Integer getApplicationStreamId() {
return this.applicationStreamId;
}
public final Integer getCallStreamId() {
return this.callStreamId;
}
public final String getDisplayName() {
String str = this.nickname;
return str != null ? str : this.user.getUsername();
}
public final GuildMember getGuildMember() {
return this.guildMember;
}
public final String getNickname() {
return this.nickname;
}
public final StreamContext getStreamContext() {
return this.streamContext;
}
public final StoreVideoStreams.UserStreams getStreams() {
return this.streams;
}
public final User getUser() {
return this.user;
}
public final VoiceState getVoiceState() {
return this.voiceState;
}
public final String getWatchingStream() {
return this.watchingStream;
}
public int hashCode() {
User user = this.user;
int i = 0;
int hashCode = (user != null ? user.hashCode() : 0) * 31;
VoiceState voiceState = this.voiceState;
int hashCode2 = (hashCode + (voiceState != null ? voiceState.hashCode() : 0)) * 31;
boolean z2 = this.isRinging;
int i2 = 1;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
int i6 = (hashCode2 + i3) * 31;
StoreVideoStreams.UserStreams userStreams = this.streams;
int hashCode3 = (i6 + (userStreams != null ? userStreams.hashCode() : 0)) * 31;
boolean z3 = this.isMe;
if (z3) {
z3 = true;
}
int i7 = z3 ? 1 : 0;
int i8 = z3 ? 1 : 0;
int i9 = z3 ? 1 : 0;
int i10 = (hashCode3 + i7) * 31;
GuildMember guildMember = this.guildMember;
int hashCode4 = (i10 + (guildMember != null ? guildMember.hashCode() : 0)) * 31;
String str = this.watchingStream;
int hashCode5 = (hashCode4 + (str != null ? str.hashCode() : 0)) * 31;
StreamContext streamContext = this.streamContext;
int hashCode6 = (hashCode5 + (streamContext != null ? streamContext.hashCode() : 0)) * 31;
boolean z4 = this.isBooster;
if (z4) {
z4 = true;
}
int i11 = z4 ? 1 : 0;
int i12 = z4 ? 1 : 0;
int i13 = z4 ? 1 : 0;
int i14 = (hashCode6 + i11) * 31;
StoreMediaSettings.VoiceConfiguration voiceConfiguration = this.voiceConfiguration;
if (voiceConfiguration != null) {
i = voiceConfiguration.hashCode();
}
int i15 = (i14 + i) * 31;
boolean z5 = this._isSpeaking;
if (!z5) {
i2 = z5 ? 1 : 0;
}
return i15 + i2;
}
public final boolean isBooster() {
return this.isBooster;
}
public final boolean isConnected() {
return this.voiceState != null;
}
public final boolean isDeafened() {
return this.isDeafened;
}
public final boolean isInvitedToSpeak() {
return this.isInvitedToSpeak;
}
public final boolean isMe() {
return this.isMe;
}
public final boolean isMuted() {
return this.isMuted;
}
public final boolean isRequestingToSpeak() {
return this.isRequestingToSpeak;
}
public final boolean isRinging() {
return this.isRinging;
}
public final boolean isSpeaking() {
return this.isSpeaking;
}
public String toString() {
StringBuilder K = a.K("VoiceUser(user=");
K.append(this.user);
K.append(", voiceState=");
K.append(this.voiceState);
K.append(", isRinging=");
K.append(this.isRinging);
K.append(", streams=");
K.append(this.streams);
K.append(", isMe=");
K.append(this.isMe);
K.append(", guildMember=");
K.append(this.guildMember);
K.append(", watchingStream=");
K.append(this.watchingStream);
K.append(", streamContext=");
K.append(this.streamContext);
K.append(", isBooster=");
K.append(this.isBooster);
K.append(", voiceConfiguration=");
K.append(this.voiceConfiguration);
K.append(", _isSpeaking=");
return a.F(K, this._isSpeaking, ")");
}
}
public StoreVoiceParticipants(StoreStream storeStream) {
m.checkNotNullParameter(storeStream, "stream");
this.stream = storeStream;
}
public static final /* synthetic */ Map access$create(StoreVoiceParticipants storeVoiceParticipants, MeUser meUser, Collection collection, Map map, Set set, Collection collection2, Map map2, Map map3, Map map4, StoreMediaSettings.VoiceConfiguration voiceConfiguration, Map map5) {
return storeVoiceParticipants.create(meUser, collection, map, set, collection2, map2, map3, map4, voiceConfiguration, map5);
}
public static final /* synthetic */ Observable access$getOtherVoiceUsers(StoreVoiceParticipants storeVoiceParticipants, Channel channel, Map map) {
return storeVoiceParticipants.getOtherVoiceUsers(channel, map);
}
public static final /* synthetic */ Observable access$getStreamContextsForUsers(StoreVoiceParticipants storeVoiceParticipants, List list) {
return storeVoiceParticipants.getStreamContextsForUsers(list);
}
private final Map<Long, VoiceUser> create(MeUser meUser, Collection<? extends User> collection, Map<Long, VoiceState> map, Set<Long> set, Collection<Long> collection2, Map<Long, StoreVideoStreams.UserStreams> map2, Map<Long, GuildMember> map3, Map<String, ? extends List<Long>> map4, StoreMediaSettings.VoiceConfiguration voiceConfiguration, Map<Long, StreamContext> map5) {
LinkedHashMap linkedHashMap = new LinkedHashMap();
LinkedHashMap linkedHashMap2 = new LinkedHashMap();
for (Map.Entry<String, ? extends List<Long>> entry : map4.entrySet()) {
if (((List) entry.getValue()).contains(Long.valueOf(meUser.getId()))) {
linkedHashMap2.put(entry.getKey(), entry.getValue());
}
}
ArrayList arrayList = new ArrayList(linkedHashMap2.size());
for (Map.Entry entry2 : linkedHashMap2.entrySet()) {
arrayList.add((String) entry2.getKey());
}
String str = (String) u.firstOrNull((List<? extends Object>) arrayList);
VoiceState voiceState = map.get(Long.valueOf(meUser.getId()));
boolean contains = collection2.contains(Long.valueOf(meUser.getId()));
StoreVideoStreams.UserStreams userStreams = map2.get(Long.valueOf(meUser.getId()));
GuildMember guildMember = map3.get(Long.valueOf(meUser.getId()));
GuildMember guildMember2 = map3.get(Long.valueOf(meUser.getId()));
linkedHashMap.put(Long.valueOf(meUser.getId()), new VoiceUser(meUser, voiceState, contains, userStreams, true, guildMember, str, null, (guildMember2 != null ? guildMember2.getPremiumSince() : null) != null, voiceConfiguration, set.contains(Long.valueOf(meUser.getId()))));
ArrayList<VoiceUser> arrayList2 = new ArrayList(o.collectionSizeOrDefault(collection, 10));
for (User user : collection) {
LinkedHashMap linkedHashMap3 = new LinkedHashMap();
for (Map.Entry<String, ? extends List<Long>> entry3 : map4.entrySet()) {
if (((List) entry3.getValue()).contains(Long.valueOf(user.getId()))) {
linkedHashMap3.put(entry3.getKey(), entry3.getValue());
}
}
ArrayList arrayList3 = new ArrayList(linkedHashMap3.size());
for (Map.Entry entry4 : linkedHashMap3.entrySet()) {
arrayList3.add((String) entry4.getKey());
}
String str2 = (String) u.firstOrNull((List<? extends Object>) arrayList3);
VoiceState voiceState2 = (VoiceState) a.c(user, map);
boolean contains2 = collection2.contains(Long.valueOf(user.getId()));
StoreVideoStreams.UserStreams userStreams2 = (StoreVideoStreams.UserStreams) a.c(user, map2);
GuildMember guildMember3 = (GuildMember) a.c(user, map3);
StreamContext streamContext = (StreamContext) a.c(user, map5);
GuildMember guildMember4 = (GuildMember) a.c(user, map3);
arrayList2.add(new VoiceUser(user, voiceState2, contains2, userStreams2, false, guildMember3, str2, streamContext, (guildMember4 != null ? guildMember4.getPremiumSince() : null) != null, voiceConfiguration, set.contains(Long.valueOf(user.getId()))));
}
for (VoiceUser voiceUser : arrayList2) {
linkedHashMap.put(Long.valueOf(voiceUser.getUser().getId()), voiceUser);
}
return linkedHashMap;
}
private final Observable<Collection<User>> getOtherVoiceUsers(Channel channel, Map<Long, VoiceState> map) {
if (AnimatableValueParser.t1(channel)) {
j jVar = new j(AnimatableValueParser.G0(channel));
m.checkNotNullExpressionValue(jVar, "Observable.just(channel.getRecipients())");
return jVar;
} else if (AnimatableValueParser.m1(channel)) {
Observable<R> Y = StoreStream.Companion.getUsers().observeMeId().Y(new StoreVoiceParticipants$getOtherVoiceUsers$1(channel, map));
m.checkNotNullExpressionValue(Y, "StoreStream\n … }\n }");
return Y;
} else {
j jVar2 = new j(n.emptyList());
m.checkNotNullExpressionValue(jVar2, "Observable.just(emptyList())");
return jVar2;
}
}
private final Observable<Map<Long, StreamContext>> getStreamContextsForUsers(List<Long> list) {
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(list, 10));
for (Iterator it = list.iterator(); it.hasNext(); it = it) {
arrayList.add(new StreamContextService(null, null, null, null, null, null, null, null, 255, null).getForUser(((Number) it.next()).longValue(), true));
}
Observable<Map<Long, StreamContext>> b = Observable.b(arrayList, new StoreVoiceParticipants$getStreamContextsForUsers$1(list));
m.checkNotNullExpressionValue(b, "Observable\n .comb…}\n map\n }");
return b;
}
public final Observable<Map<Long, VoiceUser>> get(long j) {
Observable<R> Y = StoreStream.Companion.getChannels().observeChannel(j).Y(new StoreVoiceParticipants$get$1(this, j));
m.checkNotNullExpressionValue(Y, "StoreStream\n .get… }\n }\n }");
Observable<Map<Long, VoiceUser>> r = ObservableExtensionsKt.computationLatest(Y).r();
m.checkNotNullExpressionValue(r, "StoreStream\n .get… .distinctUntilChanged()");
return r;
}
public final StoreStream getStream() {
return this.stream;
}
@Override // com.discord.stores.Store
public void init(Context context) {
m.checkNotNullParameter(context, "context");
super.init(context);
ObservableExtensionsKt.appSubscribe$default(this.stream.getVoiceChannelSelected$app_productionBetaRelease().observeSelectedVoiceChannelId(), StoreVoiceParticipants.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreVoiceParticipants$init$1(this), 62, (Object) null);
}
public final void selectParticipant(Long l) {
this.selectedParticipantSubject.onNext(l);
}
}