discord-jadx/app/src/main/java/com/discord/widgets/guilds/invite/InviteJoinHelper$joinViaInv...

413 lines
22 KiB
Java

package com.discord.widgets.guilds.invite;
import android.content.Context;
import c.a.d.j;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.R;
import com.discord.api.channel.Channel;
import com.discord.api.guild.Guild;
import com.discord.api.guild.GuildFeature;
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
import com.discord.api.guildscheduledevent.GuildScheduledEventStatus;
import com.discord.api.permission.Permission;
import com.discord.app.AppFragment;
import com.discord.models.domain.ModelInvite;
import com.discord.stores.StoreStream;
import com.discord.utilities.channel.ChannelSelector;
import com.discord.utilities.coroutines.RxCoroutineExtensionsKt;
import com.discord.utilities.error.Error;
import com.discord.utilities.features.GrowthTeamFeatures;
import com.discord.utilities.guilds.MemberVerificationUtils;
import com.discord.utilities.permissions.PermissionUtils;
import com.discord.utilities.rest.RestAPI;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.widgets.hubs.HubEmailArgs;
import com.discord.widgets.hubs.HubEmailEntryPoint;
import com.discord.widgets.hubs.WidgetHubEmailFlow;
import d0.l;
import d0.w.g;
import d0.w.h.b;
import d0.w.h.c;
import d0.w.i.a.e;
import d0.w.i.a.k;
import d0.z.d.m;
import java.util.List;
import java.util.concurrent.CancellationException;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Ref$ObjectRef;
import kotlinx.coroutines.CoroutineScope;
/* compiled from: InviteJoinHelper.kt */
@e(c = "com.discord.widgets.guilds.invite.InviteJoinHelper$joinViaInvite$4", f = "InviteJoinHelper.kt", l = {70, 99, 101, 103, 139, 170}, m = "invokeSuspend")
public final class InviteJoinHelper$joinViaInvite$4 extends k implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
public final /* synthetic */ AppFragment $fragment;
public final /* synthetic */ ModelInvite $invite;
public final /* synthetic */ String $location;
public final /* synthetic */ Function2 $onInviteFlowFinished;
public final /* synthetic */ Function2 $onInvitePostError;
public final /* synthetic */ Function2 $onInvitePostSuccess;
public Object L$0;
public Object L$1;
public Object L$2;
public int label;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public InviteJoinHelper$joinViaInvite$4(AppFragment appFragment, ModelInvite modelInvite, String str, Function2 function2, Function2 function22, Function2 function23, Continuation continuation) {
super(2, continuation);
this.$fragment = appFragment;
this.$invite = modelInvite;
this.$location = str;
this.$onInvitePostSuccess = function2;
this.$onInvitePostError = function22;
this.$onInviteFlowFinished = function23;
}
@Override // d0.w.i.a.a
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
m.checkNotNullParameter(continuation, "completion");
return new InviteJoinHelper$joinViaInvite$4(this.$fragment, this.$invite, this.$location, this.$onInvitePostSuccess, this.$onInvitePostError, this.$onInviteFlowFinished, continuation);
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation<? super Unit> continuation) {
return ((InviteJoinHelper$joinViaInvite$4) create(coroutineScope, continuation)).invokeSuspend(Unit.a);
}
/* JADX WARNING: Removed duplicated region for block: B:124:0x02bc */
/* JADX WARNING: Removed duplicated region for block: B:125:0x02ca */
/* JADX WARNING: Removed duplicated region for block: B:137:0x031e */
/* JADX WARNING: Removed duplicated region for block: B:140:0x032f A[RETURN] */
/* JADX WARNING: Removed duplicated region for block: B:67:0x0184 */
/* JADX WARNING: Removed duplicated region for block: B:71:0x01b0 A[RETURN] */
/* JADX WARNING: Removed duplicated region for block: B:74:0x01c2 A[RETURN] */
/* JADX WARNING: Removed duplicated region for block: B:75:0x01c3 */
/* JADX WARNING: Removed duplicated region for block: B:78:0x01d0 */
/* JADX WARNING: Removed duplicated region for block: B:91:0x021b */
/* JADX WARNING: Removed duplicated region for block: B:94:0x0227 */
/* JADX WARNING: Unknown variable types count: 2 */
@Override // d0.w.i.a.a
public final Object invokeSuspend(Object obj) {
ModelInvite modelInvite;
Function2 function2;
Ref$ObjectRef ref$ObjectRef;
Object obj2;
Channel channel;
Long boxLong;
boolean z2;
Boolean boxBoolean;
Boolean boxBoolean2;
Object obj3;
Ref$ObjectRef ref$ObjectRef2;
ModelInvite modelInvite2;
Function2 function22;
Object obj4;
Long boxLong2;
List<GuildFeature> l;
List<GuildFeature> l2;
List<GuildFeature> l3;
Object coroutine_suspended = c.getCOROUTINE_SUSPENDED();
boolean z3 = false;
switch (this.label) {
case 0:
l.throwOnFailure(obj);
ref$ObjectRef2 = new Ref$ObjectRef();
ref$ObjectRef2.element = this.$fragment.requireContext();
Ref$ObjectRef ref$ObjectRef3 = new Ref$ObjectRef();
?? parentFragmentManager = this.$fragment.getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "fragment.parentFragmentManager");
ref$ObjectRef3.element = parentFragmentManager;
Guild guild = this.$invite.getGuild();
boolean z4 = (guild == null || (l3 = guild.l()) == null || !l3.contains(GuildFeature.MEMBER_VERIFICATION_GATE_ENABLED)) ? false : true;
Guild guild2 = this.$invite.getGuild();
boolean z5 = (guild2 == null || (l2 = guild2.l()) == null || l2.contains(GuildFeature.PREVIEW_ENABLED)) ? false : true;
Guild guild3 = this.$invite.getGuild();
boolean z6 = (guild3 == null || (l = guild3.l()) == null || !l.contains(GuildFeature.HUB)) ? false : true;
if (z6 && !GrowthTeamFeatures.INSTANCE.isHubEnabled()) {
c.a.d.m.g(ref$ObjectRef2.element, R.string.discord_u_coming_soon_to_mobile, 0, null, 12);
} else if (!z6 || !GrowthTeamFeatures.INSTANCE.isHubEmailConnectionEnabled()) {
if (z4 && z5) {
this.L$0 = ref$ObjectRef2;
this.L$1 = ref$ObjectRef3;
this.L$2 = this;
this.label = 1;
g gVar = new g(b.intercepted(this));
MemberVerificationUtils memberVerificationUtils = MemberVerificationUtils.INSTANCE;
Context context = ref$ObjectRef2.element;
Guild guild4 = this.$invite.getGuild();
memberVerificationUtils.maybeShowVerificationGate(context, ref$ObjectRef3.element, (guild4 == null || (boxLong2 = d0.w.i.a.b.boxLong(guild4.p())) == null) ? -1 : boxLong2.longValue(), this.$location, this.$invite, new InviteJoinHelper$joinViaInvite$4$hasCompletedMembershipGate$1$1(gVar), new InviteJoinHelper$joinViaInvite$4$hasCompletedMembershipGate$1$2(gVar));
obj4 = gVar.getOrThrow();
if (obj4 == c.getCOROUTINE_SUSPENDED()) {
d0.w.i.a.g.probeCoroutineSuspended(this);
}
if (obj4 == coroutine_suspended) {
return coroutine_suspended;
}
if (!((Boolean) obj4).booleanValue()) {
return Unit.a;
}
}
this.L$0 = ref$ObjectRef2;
this.L$1 = null;
this.L$2 = null;
this.label = 2;
obj3 = RxCoroutineExtensionsKt.appAwaitSingle(ObservableExtensionsKt.ui(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().postInviteCode(this.$invite, this.$location), false, 1, null)), ref$ObjectRef2.element, this);
if (obj3 == coroutine_suspended) {
return coroutine_suspended;
}
modelInvite2 = (ModelInvite) obj3;
function22 = this.$onInvitePostSuccess;
this.L$0 = ref$ObjectRef2;
this.L$1 = modelInvite2;
this.label = 3;
if (function22.invoke(modelInvite2, this) == coroutine_suspended) {
return coroutine_suspended;
}
ref$ObjectRef = ref$ObjectRef2;
modelInvite = modelInvite2;
channel = this.$invite.getChannel();
if (channel != null) {
m.checkNotNullExpressionValue(channel, "channel");
if (AnimatableValueParser.m1(channel)) {
Long l4 = StoreStream.Companion.getPermissions().getPermissionsByChannel().get(d0.w.i.a.b.boxLong(channel.h()));
if ((l4 == null || (boxBoolean2 = d0.w.i.a.b.boxBoolean(PermissionUtils.can(Permission.CONNECT, d0.w.i.a.b.boxLong(l4.longValue())))) == null) ? false : boxBoolean2.booleanValue()) {
z2 = true;
boxBoolean = d0.w.i.a.b.boxBoolean(z2);
if (boxBoolean != null) {
z3 = boxBoolean.booleanValue();
}
}
}
z2 = false;
boxBoolean = d0.w.i.a.b.boxBoolean(z2);
if (boxBoolean != null) {
}
}
if (this.$invite.getGuild() != null) {
Guild guild5 = this.$invite.getGuild();
if (((guild5 == null || (boxLong = d0.w.i.a.b.boxLong(guild5.p())) == null) ? 0 : boxLong.longValue()) > 0) {
if (this.$invite.getGuildScheduledEvent() != null) {
GuildScheduledEvent guildScheduledEvent = this.$invite.getGuildScheduledEvent();
if ((guildScheduledEvent != null ? guildScheduledEvent.k() : null) != GuildScheduledEventStatus.ACTIVE) {
InviteJoinHelper.access$navigateToGuild(InviteJoinHelper.INSTANCE, this.$invite);
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
modelInvite = this.$invite;
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
return coroutine_suspended;
}
return Unit.a;
}
}
Channel channel2 = this.$invite.getChannel();
if (channel2 == null || !AnimatableValueParser.D1(channel2)) {
Channel channel3 = this.$invite.getChannel();
if (channel3 == null || !AnimatableValueParser.x1(channel3)) {
InviteJoinHelper.access$navigateToChannel(InviteJoinHelper.INSTANCE, ref$ObjectRef.element, this.$fragment, this.$invite);
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
}
return Unit.a;
}
if (!z3) {
InviteJoinHelper.access$navigateToGuild(InviteJoinHelper.INSTANCE, this.$invite);
} else {
InviteJoinHelper.access$navigateToChannel(InviteJoinHelper.INSTANCE, ref$ObjectRef.element, this.$fragment, this.$invite);
}
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
}
return Unit.a;
} else if (!z3) {
InviteJoinHelper.access$navigateToGuild(InviteJoinHelper.INSTANCE, this.$invite);
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
}
return Unit.a;
} else {
this.L$0 = ref$ObjectRef;
this.L$1 = modelInvite;
this.L$2 = this;
this.label = 5;
g gVar2 = new g(b.intercepted(this));
this.$fragment.requestMicrophone(new InviteJoinHelper$joinViaInvite$4$hasMicrophonePermissions$1$1(gVar2), new InviteJoinHelper$joinViaInvite$4$hasMicrophonePermissions$1$2(gVar2));
obj2 = gVar2.getOrThrow();
if (obj2 == c.getCOROUTINE_SUSPENDED()) {
d0.w.i.a.g.probeCoroutineSuspended(this);
}
if (obj2 == coroutine_suspended) {
return coroutine_suspended;
}
if (!((Boolean) obj2).booleanValue()) {
InviteJoinHelper.access$navigateToChannel(InviteJoinHelper.INSTANCE, ref$ObjectRef.element, this.$fragment, this.$invite);
} else {
InviteJoinHelper.access$navigateToGuild(InviteJoinHelper.INSTANCE, this.$invite);
}
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
}
return Unit.a;
}
}
}
ChannelSelector.selectChannel$default(ChannelSelector.Companion.getInstance(), this.$invite.getChannel(), null, null, 6, null);
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
}
return Unit.a;
} else {
Context context2 = ref$ObjectRef2.element;
HubEmailEntryPoint hubEmailEntryPoint = HubEmailEntryPoint.Invite;
Guild guild6 = this.$invite.getGuild();
String v = guild6 != null ? guild6.v() : null;
if (v == null) {
v = "";
}
j.d(context2, WidgetHubEmailFlow.class, new HubEmailArgs(v, this.$invite.getApproximateMemberCount(), hubEmailEntryPoint));
}
modelInvite = null;
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
}
return Unit.a;
case 1:
InviteJoinHelper$joinViaInvite$4 inviteJoinHelper$joinViaInvite$4 = (InviteJoinHelper$joinViaInvite$4) this.L$2;
Ref$ObjectRef ref$ObjectRef4 = (Ref$ObjectRef) this.L$1;
ref$ObjectRef2 = (Ref$ObjectRef) this.L$0;
l.throwOnFailure(obj);
obj4 = obj;
if (!((Boolean) obj4).booleanValue()) {
}
this.L$0 = ref$ObjectRef2;
this.L$1 = null;
this.L$2 = null;
this.label = 2;
obj3 = RxCoroutineExtensionsKt.appAwaitSingle(ObservableExtensionsKt.ui(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().postInviteCode(this.$invite, this.$location), false, 1, null)), ref$ObjectRef2.element, this);
if (obj3 == coroutine_suspended) {
}
modelInvite2 = (ModelInvite) obj3;
function22 = this.$onInvitePostSuccess;
this.L$0 = ref$ObjectRef2;
this.L$1 = modelInvite2;
this.label = 3;
if (function22.invoke(modelInvite2, this) == coroutine_suspended) {
}
break;
case 2:
ref$ObjectRef2 = (Ref$ObjectRef) this.L$0;
l.throwOnFailure(obj);
obj3 = obj;
modelInvite2 = (ModelInvite) obj3;
function22 = this.$onInvitePostSuccess;
this.L$0 = ref$ObjectRef2;
this.L$1 = modelInvite2;
this.label = 3;
if (function22.invoke(modelInvite2, this) == coroutine_suspended) {
}
break;
case 3:
modelInvite = (ModelInvite) this.L$1;
ref$ObjectRef = (Ref$ObjectRef) this.L$0;
try {
l.throwOnFailure(obj);
channel = this.$invite.getChannel();
if (channel != null) {
}
if (this.$invite.getGuild() != null) {
}
ChannelSelector.selectChannel$default(ChannelSelector.Companion.getInstance(), this.$invite.getChannel(), null, null, 6, null);
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
}
return Unit.a;
} catch (CancellationException e) {
Function2 function23 = this.$onInvitePostError;
Throwable cause = e.getCause();
Error create = cause != null ? Error.create(cause) : null;
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 4;
if (function23.invoke(create, this) == coroutine_suspended) {
return coroutine_suspended;
}
}
break;
case 4:
l.throwOnFailure(obj);
return Unit.a;
case 5:
InviteJoinHelper$joinViaInvite$4 inviteJoinHelper$joinViaInvite$42 = (InviteJoinHelper$joinViaInvite$4) this.L$2;
modelInvite = (ModelInvite) this.L$1;
l.throwOnFailure(obj);
ref$ObjectRef = (Ref$ObjectRef) this.L$0;
obj2 = obj;
if (!((Boolean) obj2).booleanValue()) {
}
function2 = this.$onInviteFlowFinished;
if (modelInvite == null) {
}
this.L$0 = null;
this.L$1 = null;
this.L$2 = null;
this.label = 6;
if (function2.invoke(modelInvite, this) == coroutine_suspended) {
}
return Unit.a;
case 6:
l.throwOnFailure(obj);
return Unit.a;
default:
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
}
}