discord-jadx/app/src/main/java/com/discord/utilities/streams/StreamContextService$getFor...

122 lines
8.2 KiB
Java

package com.discord.utilities.streams;
import com.discord.api.channel.Channel;
import com.discord.api.voice.state.VoiceState;
import com.discord.models.domain.ModelApplicationStream;
import com.discord.models.guild.Guild;
import com.discord.models.member.GuildMember;
import com.discord.models.user.MeUser;
import com.discord.models.user.User;
import com.discord.stores.StoreApplicationStreamPreviews;
import com.discord.stores.StoreApplicationStreaming;
import com.discord.stores.StoreUser;
import com.discord.utilities.permissions.PermissionUtils;
import com.discord.utilities.rx.ObservableCombineLatestOverloadsKt;
import com.discord.utilities.streams.StreamContext;
import d0.z.d.m;
import d0.z.d.o;
import j0.k.b;
import j0.l.e.j;
import java.util.Map;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.functions.Function10;
import rx.Observable;
/* compiled from: StreamContextService.kt */
public final class StreamContextService$getForUser$1<T, R> implements b<ModelApplicationStream, Observable<? extends StreamContext>> {
public final /* synthetic */ boolean $includePreview;
public final /* synthetic */ long $userId;
public final /* synthetic */ StreamContextService this$0;
/* compiled from: StreamContextService.kt */
/* renamed from: com.discord.utilities.streams.StreamContextService$getForUser$1$1 reason: invalid class name */
public static final class AnonymousClass1<T, R> implements b<Map<Long, ? extends GuildMember>, GuildMember> {
public final /* synthetic */ StreamContextService$getForUser$1 this$0;
public AnonymousClass1(StreamContextService$getForUser$1 streamContextService$getForUser$1) {
this.this$0 = streamContextService$getForUser$1;
}
public final GuildMember call(Map<Long, GuildMember> map) {
return map.get(Long.valueOf(this.this$0.$userId));
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // j0.k.b
public /* bridge */ /* synthetic */ GuildMember call(Map<Long, ? extends GuildMember> map) {
return call((Map<Long, GuildMember>) map);
}
}
/* compiled from: StreamContextService.kt */
/* renamed from: com.discord.utilities.streams.StreamContextService$getForUser$1$2 reason: invalid class name */
public static final class AnonymousClass2<T, R> implements b<GuildMember, String> {
public static final AnonymousClass2 INSTANCE = new AnonymousClass2();
public final String call(GuildMember guildMember) {
if (guildMember != null) {
return guildMember.getNick();
}
return null;
}
}
/* compiled from: StreamContextService.kt */
/* renamed from: com.discord.utilities.streams.StreamContextService$getForUser$1$3 reason: invalid class name */
public static final class AnonymousClass3 extends o implements Function10<Guild, StoreApplicationStreamPreviews.StreamPreview, Long, User, MeUser, String, Map<Long, ? extends VoiceState>, Channel, Long, StoreApplicationStreaming.ActiveApplicationStream, StreamContext> {
public final /* synthetic */ ModelApplicationStream $stream;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass3(ModelApplicationStream modelApplicationStream) {
super(10);
this.$stream = modelApplicationStream;
}
public final StreamContext invoke(Guild guild, StoreApplicationStreamPreviews.StreamPreview streamPreview, Long l, User user, MeUser meUser, String str, Map<Long, VoiceState> map, Channel channel, long j, StoreApplicationStreaming.ActiveApplicationStream activeApplicationStream) {
m.checkNotNullParameter(meUser, "me");
m.checkNotNullParameter(map, "voiceStates");
if (((this.$stream instanceof ModelApplicationStream.GuildStream) && guild == null) || user == null) {
return null;
}
int B = channel != null ? channel.B() : 0;
return new StreamContext(this.$stream, guild, streamPreview, (!(this.$stream instanceof ModelApplicationStream.GuildStream) || PermissionUtils.can(1048576, l) || (channel != null && (channel.h() > j ? 1 : (channel.h() == j ? 0 : -1)) == 0)) ? (!(B > 0 && map.size() >= B) || PermissionUtils.can(16, l)) ? StreamContext.Joinability.CAN_CONNECT : StreamContext.Joinability.VOICE_CHANNEL_FULL : StreamContext.Joinability.MISSING_PERMISSIONS, user, str, activeApplicationStream != null && activeApplicationStream.getState().isStreamActive() && m.areEqual(activeApplicationStream.getStream(), this.$stream), user.getId() == meUser.getId());
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object] */
@Override // kotlin.jvm.functions.Function10
public /* bridge */ /* synthetic */ StreamContext invoke(Guild guild, StoreApplicationStreamPreviews.StreamPreview streamPreview, Long l, User user, MeUser meUser, String str, Map<Long, ? extends VoiceState> map, Channel channel, Long l2, StoreApplicationStreaming.ActiveApplicationStream activeApplicationStream) {
return invoke(guild, streamPreview, l, user, meUser, str, (Map<Long, VoiceState>) map, channel, l2.longValue(), activeApplicationStream);
}
}
public StreamContextService$getForUser$1(StreamContextService streamContextService, boolean z2, long j) {
this.this$0 = streamContextService;
this.$includePreview = z2;
this.$userId = j;
}
public final Observable<? extends StreamContext> call(ModelApplicationStream modelApplicationStream) {
long j;
if (modelApplicationStream == null) {
return new j(null);
}
if (modelApplicationStream instanceof ModelApplicationStream.GuildStream) {
j = ((ModelApplicationStream.GuildStream) modelApplicationStream).getGuildId();
} else if (modelApplicationStream instanceof ModelApplicationStream.CallStream) {
j = 0;
} else {
throw new NoWhenBranchMatchedException();
}
Observable<Guild> observeGuild = StreamContextService.access$getGuildStore$p(this.this$0).observeGuild(j);
StreamContextService streamContextService = this.this$0;
Observable access$getPreviewObservable = StreamContextService.access$getPreviewObservable(streamContextService, modelApplicationStream, this.$includePreview, StreamContextService.access$getApplicationStreamPreviewStore$p(streamContextService));
Observable<Long> observePermissionsForChannel = StreamContextService.access$getPermissionsStore$p(this.this$0).observePermissionsForChannel(modelApplicationStream.getChannelId());
Observable<User> observeUser = StreamContextService.access$getUserStore$p(this.this$0).observeUser(this.$userId);
Observable observeMe$default = StoreUser.observeMe$default(StreamContextService.access$getUserStore$p(this.this$0), false, 1, null);
Observable<R> r = StreamContextService.access$getGuildStore$p(this.this$0).observeComputed(j).F(new AnonymousClass1(this)).F(AnonymousClass2.INSTANCE).r();
m.checkNotNullExpressionValue(r, "guildStore\n … .distinctUntilChanged()");
return ObservableCombineLatestOverloadsKt.combineLatest(observeGuild, access$getPreviewObservable, observePermissionsForChannel, observeUser, observeMe$default, r, StreamContextService.access$getVoiceStateStore$p(this.this$0).observe(j, modelApplicationStream.getChannelId()), StreamContextService.access$getChannelStore$p(this.this$0).observeChannel(modelApplicationStream.getChannelId()), StreamContextService.access$getVoiceChannelSelectedStore$p(this.this$0).observeSelectedVoiceChannelId(), StreamContextService.access$getApplicationStreamingStore$p(this.this$0).observeActiveStream(), new AnonymousClass3(modelApplicationStream));
}
}