2021-08-03 07:33:18 +00:00
|
|
|
package com.discord.widgets.guilds.invite;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.view.View;
|
|
|
|
import androidx.fragment.app.Fragment;
|
2021-11-24 07:22:14 +00:00
|
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.a.d.f0;
|
|
|
|
import b.a.d.h0;
|
|
|
|
import b.a.d.j;
|
|
|
|
import b.d.b.a.a;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.R;
|
2021-08-20 02:22:46 +00:00
|
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.app.AppFragment;
|
2021-09-11 06:38:47 +00:00
|
|
|
import com.discord.databinding.WidgetGuildInvitePageBinding;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.models.domain.ModelInvite;
|
2021-11-05 06:48:17 +00:00
|
|
|
import com.discord.stores.StoreGuilds;
|
2021-08-20 02:22:46 +00:00
|
|
|
import com.discord.stores.StoreInviteSettings;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.stores.StoreStream;
|
2021-11-05 06:48:17 +00:00
|
|
|
import com.discord.stores.StoreUser;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
|
|
import com.discord.utilities.error.Error;
|
2021-11-05 06:48:17 +00:00
|
|
|
import com.discord.utilities.guildscheduledevent.GuildScheduledEventUtilitiesKt;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
2021-11-24 07:22:14 +00:00
|
|
|
import com.discord.widgets.guilds.invite.GuildInviteViewModel;
|
2021-08-20 02:22:46 +00:00
|
|
|
import com.discord.widgets.guildscheduledevent.GuildScheduledEventItemView;
|
|
|
|
import com.discord.widgets.guildscheduledevent.GuildScheduledEventModel;
|
|
|
|
import com.discord.widgets.guildscheduledevent.GuildScheduledEventModelKt;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.google.android.material.button.MaterialButton;
|
2021-11-24 07:22:14 +00:00
|
|
|
import d0.z.d.a0;
|
2021-11-02 06:38:17 +00:00
|
|
|
import d0.z.d.m;
|
2021-11-24 07:22:14 +00:00
|
|
|
import kotlin.Lazy;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
2021-08-03 07:33:18 +00:00
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import kotlin.reflect.KProperty;
|
|
|
|
/* compiled from: WidgetGuildInvite.kt */
|
|
|
|
public final class WidgetGuildInvite extends AppFragment {
|
2021-11-05 06:48:17 +00:00
|
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetGuildInvite.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildInvitePageBinding;", 0)};
|
2021-08-03 07:33:18 +00:00
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
private static final String EXTRA_CODE = "EXTRA_CODE";
|
|
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildInvite$binding$2.INSTANCE, null, 2, null);
|
2021-11-24 07:22:14 +00:00
|
|
|
private final StoreInviteSettings.InviteCode inviteCode;
|
|
|
|
private final Lazy viewModel$delegate;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
/* compiled from: WidgetGuildInvite.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
2021-08-20 02:22:46 +00:00
|
|
|
public final void launch(Context context, StoreInviteSettings.InviteCode inviteCode) {
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullParameter(context, "context");
|
2021-08-20 02:22:46 +00:00
|
|
|
m.checkNotNullParameter(inviteCode, "inviteCode");
|
2021-08-03 07:33:18 +00:00
|
|
|
Intent intent = new Intent();
|
2021-08-20 02:22:46 +00:00
|
|
|
intent.putExtra(WidgetGuildInvite.EXTRA_CODE, inviteCode);
|
2021-08-13 06:23:11 +00:00
|
|
|
j.d(context, WidgetGuildInvite.class, intent);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WidgetGuildInvite() {
|
2021-09-11 06:38:47 +00:00
|
|
|
super(R.layout.widget_guild_invite_page);
|
2021-11-24 07:22:14 +00:00
|
|
|
WidgetGuildInvite$viewModel$2 widgetGuildInvite$viewModel$2 = new WidgetGuildInvite$viewModel$2(this);
|
|
|
|
f0 f0Var = new f0(this);
|
|
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(GuildInviteViewModel.class), new WidgetGuildInvite$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGuildInvite$viewModel$2));
|
|
|
|
this.inviteCode = (StoreInviteSettings.InviteCode) getMostRecentIntent().getParcelableExtra(EXTRA_CODE);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$configureUIFailure(WidgetGuildInvite widgetGuildInvite, Error error) {
|
|
|
|
widgetGuildInvite.configureUIFailure(error);
|
|
|
|
}
|
|
|
|
|
2021-11-24 07:22:14 +00:00
|
|
|
private final void configureLoadedUI(GuildInviteViewModel.ViewState.Loaded loaded) {
|
2021-08-25 07:02:36 +00:00
|
|
|
boolean z2;
|
2021-08-20 02:22:46 +00:00
|
|
|
GuildScheduledEventModel model;
|
2021-11-24 07:22:14 +00:00
|
|
|
ModelInvite invite = loaded.getInvite();
|
2021-08-25 07:02:36 +00:00
|
|
|
getBinding().e.configureUI(invite);
|
|
|
|
GuildScheduledEventItemView guildScheduledEventItemView = getBinding().d;
|
2021-09-11 06:38:47 +00:00
|
|
|
m.checkNotNullExpressionValue(guildScheduledEventItemView, "binding.guildInviteEventInfo");
|
2021-11-24 07:22:14 +00:00
|
|
|
GuildScheduledEvent guildScheduledEvent = invite.getGuildScheduledEvent();
|
2021-09-11 06:38:47 +00:00
|
|
|
if (guildScheduledEvent == null || (model = GuildScheduledEventModelKt.toModel(guildScheduledEvent)) == null) {
|
|
|
|
z2 = false;
|
|
|
|
} else {
|
2021-11-24 07:22:14 +00:00
|
|
|
getBinding().d.configureAsPreview(model, invite.getChannel(), GuildScheduledEventUtilitiesKt.getCreatorUserGuildMember$default(model, (StoreGuilds) null, (StoreUser) null, 3, (Object) null));
|
2021-09-11 06:38:47 +00:00
|
|
|
z2 = true;
|
2021-08-25 07:02:36 +00:00
|
|
|
}
|
2021-09-11 06:38:47 +00:00
|
|
|
guildScheduledEventItemView.setVisibility(z2 ? 0 : 8);
|
2021-12-17 21:59:34 +00:00
|
|
|
MaterialButton materialButton = getBinding().c;
|
2021-08-25 07:02:36 +00:00
|
|
|
m.checkNotNullExpressionValue(materialButton, "binding.guildInviteCancel");
|
|
|
|
materialButton.setVisibility(8);
|
2021-12-20 07:27:17 +00:00
|
|
|
MaterialButton materialButton2 = getBinding().f2382b;
|
2021-08-25 07:02:36 +00:00
|
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.guildInviteAccept");
|
|
|
|
materialButton2.setVisibility(0);
|
2021-12-20 07:27:17 +00:00
|
|
|
getBinding().f2382b.setOnClickListener(new WidgetGuildInvite$configureLoadedUI$2(this, invite));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final void configureUIFailure(Error error) {
|
2021-12-17 21:59:34 +00:00
|
|
|
MaterialButton materialButton = getBinding().c;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(materialButton, "binding.guildInviteCancel");
|
|
|
|
materialButton.setVisibility(0);
|
2021-12-20 07:27:17 +00:00
|
|
|
MaterialButton materialButton2 = getBinding().f2382b;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.guildInviteAccept");
|
|
|
|
materialButton2.setVisibility(8);
|
2021-08-20 02:22:46 +00:00
|
|
|
getBinding().e.configureUIFailure(error);
|
2021-08-03 07:33:18 +00:00
|
|
|
trackAndConsumeDynamicLinkCache(null);
|
|
|
|
}
|
|
|
|
|
2021-09-11 06:38:47 +00:00
|
|
|
private final WidgetGuildInvitePageBinding getBinding() {
|
|
|
|
return (WidgetGuildInvitePageBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-11-24 07:22:14 +00:00
|
|
|
private final GuildInviteViewModel getViewModel() {
|
|
|
|
return (GuildInviteViewModel) this.viewModel$delegate.getValue();
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final void trackAndConsumeDynamicLinkCache(ModelInvite modelInvite) {
|
2021-08-20 02:22:46 +00:00
|
|
|
String source;
|
|
|
|
String inviteCode;
|
|
|
|
String source2;
|
2021-08-03 07:33:18 +00:00
|
|
|
StoreStream.Companion.getInviteSettings().clearInviteCode();
|
2021-11-24 07:22:14 +00:00
|
|
|
if (!getViewModel().getInviteResolved()) {
|
|
|
|
getViewModel().setInviteResolved(true);
|
2021-08-03 07:33:18 +00:00
|
|
|
String str = "";
|
|
|
|
if (modelInvite != null) {
|
|
|
|
AnalyticsTracker analyticsTracker = AnalyticsTracker.INSTANCE;
|
2021-08-20 02:22:46 +00:00
|
|
|
StoreInviteSettings.InviteCode inviteCode2 = this.inviteCode;
|
|
|
|
if (!(inviteCode2 == null || (source2 = inviteCode2.getSource()) == null)) {
|
|
|
|
str = source2;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
analyticsTracker.inviteResolved(modelInvite, str);
|
|
|
|
return;
|
|
|
|
}
|
2021-08-20 02:22:46 +00:00
|
|
|
StoreInviteSettings.InviteCode inviteCode3 = this.inviteCode;
|
|
|
|
String str2 = (inviteCode3 == null || (inviteCode = inviteCode3.getInviteCode()) == null) ? str : inviteCode;
|
|
|
|
StoreInviteSettings.InviteCode inviteCode4 = this.inviteCode;
|
|
|
|
AnalyticsTracker.inviteResolveFailed$default(str2, (inviteCode4 == null || (source = inviteCode4.getSource()) == null) ? str : source, null, null, 12, null);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-24 07:22:14 +00:00
|
|
|
public final void configureUI(GuildInviteViewModel.ViewState viewState) {
|
|
|
|
m.checkNotNullParameter(viewState, "viewState");
|
|
|
|
if (viewState instanceof GuildInviteViewModel.ViewState.Invalid) {
|
|
|
|
configureUIFailure(null);
|
|
|
|
} else if (viewState instanceof GuildInviteViewModel.ViewState.Loaded) {
|
|
|
|
GuildInviteViewModel.ViewState.Loaded loaded = (GuildInviteViewModel.ViewState.Loaded) viewState;
|
|
|
|
trackAndConsumeDynamicLinkCache(loaded.getInvite());
|
|
|
|
configureLoadedUI(loaded);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-03 07:33:18 +00:00
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBound(View view) {
|
|
|
|
m.checkNotNullParameter(view, "view");
|
|
|
|
super.onViewBound(view);
|
2021-08-20 02:22:46 +00:00
|
|
|
String str = null;
|
2021-08-03 07:33:18 +00:00
|
|
|
AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null);
|
2021-08-20 02:22:46 +00:00
|
|
|
AnalyticsTracker analyticsTracker = AnalyticsTracker.INSTANCE;
|
2021-11-24 07:22:14 +00:00
|
|
|
StoreInviteSettings.InviteCode inviteCode = this.inviteCode;
|
2021-08-20 02:22:46 +00:00
|
|
|
if (inviteCode != null) {
|
|
|
|
str = inviteCode.getInviteCode();
|
|
|
|
}
|
|
|
|
analyticsTracker.impressionInviteAccept(str);
|
2021-12-17 21:59:34 +00:00
|
|
|
getBinding().c.setOnClickListener(new WidgetGuildInvite$onViewBound$1(this));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBoundOrOnResume() {
|
|
|
|
super.onViewBoundOrOnResume();
|
2021-11-24 07:22:14 +00:00
|
|
|
getViewModel().fetchInviteIfNotLoaded();
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetGuildInvite.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildInvite$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|