forked from Juby210/discord-jadx
383 lines
16 KiB
Java
383 lines
16 KiB
Java
package com.discord.widgets.guilds.join;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import b.d.b.a.a;
|
|
import com.discord.api.guild.welcome.GuildWelcomeChannel;
|
|
import com.discord.api.guild.welcome.GuildWelcomeScreen;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.stores.StoreGuildWelcomeScreens;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
import com.discord.utilities.channel.ChannelSelector;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetGuildWelcomeSheetViewModel.kt */
|
|
public final class WidgetGuildWelcomeSheetViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final long guildId;
|
|
|
|
/* compiled from: WidgetGuildWelcomeSheetViewModel.kt */
|
|
/* renamed from: com.discord.widgets.guilds.join.WidgetGuildWelcomeSheetViewModel$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
public final /* synthetic */ WidgetGuildWelcomeSheetViewModel this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(WidgetGuildWelcomeSheetViewModel widgetGuildWelcomeSheetViewModel) {
|
|
super(1);
|
|
this.this$0 = widgetGuildWelcomeSheetViewModel;
|
|
}
|
|
|
|
/* 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 // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(StoreState storeState) {
|
|
invoke(storeState);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(StoreState storeState) {
|
|
m.checkNotNullParameter(storeState, "storeState");
|
|
WidgetGuildWelcomeSheetViewModel.access$handleStoreState(this.this$0, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetGuildWelcomeSheetViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final Observable<StoreState> observeStores(long j) {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable<StoreState> j2 = Observable.j(companion.getGuilds().observeGuild(j), companion.getGuildWelcomeScreens().observeGuildWelcomeScreen(j), WidgetGuildWelcomeSheetViewModel$Companion$observeStores$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(j2, "Observable\n .… )\n }");
|
|
return j2;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetGuildWelcomeSheetViewModel.kt */
|
|
public static final class StoreState {
|
|
private final Guild guild;
|
|
private final StoreGuildWelcomeScreens.State guildWelcomeScreen;
|
|
|
|
public StoreState(Guild guild, StoreGuildWelcomeScreens.State state) {
|
|
this.guild = guild;
|
|
this.guildWelcomeScreen = state;
|
|
}
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, Guild guild, StoreGuildWelcomeScreens.State state, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guild = storeState.guild;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
state = storeState.guildWelcomeScreen;
|
|
}
|
|
return storeState.copy(guild, state);
|
|
}
|
|
|
|
public final Guild component1() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final StoreGuildWelcomeScreens.State component2() {
|
|
return this.guildWelcomeScreen;
|
|
}
|
|
|
|
public final StoreState copy(Guild guild, StoreGuildWelcomeScreens.State state) {
|
|
return new StoreState(guild, state);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StoreState)) {
|
|
return false;
|
|
}
|
|
StoreState storeState = (StoreState) obj;
|
|
return m.areEqual(this.guild, storeState.guild) && m.areEqual(this.guildWelcomeScreen, storeState.guildWelcomeScreen);
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final StoreGuildWelcomeScreens.State getGuildWelcomeScreen() {
|
|
return this.guildWelcomeScreen;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Guild guild = this.guild;
|
|
int i = 0;
|
|
int hashCode = (guild != null ? guild.hashCode() : 0) * 31;
|
|
StoreGuildWelcomeScreens.State state = this.guildWelcomeScreen;
|
|
if (state != null) {
|
|
i = state.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("StoreState(guild=");
|
|
R.append(this.guild);
|
|
R.append(", guildWelcomeScreen=");
|
|
R.append(this.guildWelcomeScreen);
|
|
R.append(")");
|
|
return R.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetGuildWelcomeSheetViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: WidgetGuildWelcomeSheetViewModel.kt */
|
|
public static final class Invalid extends ViewState {
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
private Invalid() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetGuildWelcomeSheetViewModel.kt */
|
|
public static final class Loaded extends ViewState {
|
|
private final String guildDescription;
|
|
private final String guildIcon;
|
|
private final long guildId;
|
|
private final String guildName;
|
|
private final String guildShortName;
|
|
private final List<GuildWelcomeChannel> welcomeChannelsData;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Loaded(long j, String str, String str2, String str3, String str4, List<GuildWelcomeChannel> list) {
|
|
super(null);
|
|
m.checkNotNullParameter(str, "guildName");
|
|
m.checkNotNullParameter(str2, "guildShortName");
|
|
this.guildId = j;
|
|
this.guildName = str;
|
|
this.guildShortName = str2;
|
|
this.guildIcon = str3;
|
|
this.guildDescription = str4;
|
|
this.welcomeChannelsData = list;
|
|
}
|
|
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, long j, String str, String str2, String str3, String str4, List list, int i, Object obj) {
|
|
return loaded.copy((i & 1) != 0 ? loaded.guildId : j, (i & 2) != 0 ? loaded.guildName : str, (i & 4) != 0 ? loaded.guildShortName : str2, (i & 8) != 0 ? loaded.guildIcon : str3, (i & 16) != 0 ? loaded.guildDescription : str4, (i & 32) != 0 ? loaded.welcomeChannelsData : list);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.guildName;
|
|
}
|
|
|
|
public final String component3() {
|
|
return this.guildShortName;
|
|
}
|
|
|
|
public final String component4() {
|
|
return this.guildIcon;
|
|
}
|
|
|
|
public final String component5() {
|
|
return this.guildDescription;
|
|
}
|
|
|
|
public final List<GuildWelcomeChannel> component6() {
|
|
return this.welcomeChannelsData;
|
|
}
|
|
|
|
public final Loaded copy(long j, String str, String str2, String str3, String str4, List<GuildWelcomeChannel> list) {
|
|
m.checkNotNullParameter(str, "guildName");
|
|
m.checkNotNullParameter(str2, "guildShortName");
|
|
return new Loaded(j, str, str2, str3, str4, list);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Loaded)) {
|
|
return false;
|
|
}
|
|
Loaded loaded = (Loaded) obj;
|
|
return this.guildId == loaded.guildId && m.areEqual(this.guildName, loaded.guildName) && m.areEqual(this.guildShortName, loaded.guildShortName) && m.areEqual(this.guildIcon, loaded.guildIcon) && m.areEqual(this.guildDescription, loaded.guildDescription) && m.areEqual(this.welcomeChannelsData, loaded.welcomeChannelsData);
|
|
}
|
|
|
|
public final String getGuildDescription() {
|
|
return this.guildDescription;
|
|
}
|
|
|
|
public final String getGuildIcon() {
|
|
return this.guildIcon;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final String getGuildName() {
|
|
return this.guildName;
|
|
}
|
|
|
|
public final String getGuildShortName() {
|
|
return this.guildShortName;
|
|
}
|
|
|
|
public final List<GuildWelcomeChannel> getWelcomeChannelsData() {
|
|
return this.welcomeChannelsData;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int a = b.a(this.guildId) * 31;
|
|
String str = this.guildName;
|
|
int i = 0;
|
|
int hashCode = (a + (str != null ? str.hashCode() : 0)) * 31;
|
|
String str2 = this.guildShortName;
|
|
int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31;
|
|
String str3 = this.guildIcon;
|
|
int hashCode3 = (hashCode2 + (str3 != null ? str3.hashCode() : 0)) * 31;
|
|
String str4 = this.guildDescription;
|
|
int hashCode4 = (hashCode3 + (str4 != null ? str4.hashCode() : 0)) * 31;
|
|
List<GuildWelcomeChannel> list = this.welcomeChannelsData;
|
|
if (list != null) {
|
|
i = list.hashCode();
|
|
}
|
|
return hashCode4 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("Loaded(guildId=");
|
|
R.append(this.guildId);
|
|
R.append(", guildName=");
|
|
R.append(this.guildName);
|
|
R.append(", guildShortName=");
|
|
R.append(this.guildShortName);
|
|
R.append(", guildIcon=");
|
|
R.append(this.guildIcon);
|
|
R.append(", guildDescription=");
|
|
R.append(this.guildDescription);
|
|
R.append(", welcomeChannelsData=");
|
|
return a.J(R, this.welcomeChannelsData, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetGuildWelcomeSheetViewModel.kt */
|
|
public static final class Loading extends ViewState {
|
|
public static final Loading INSTANCE = new Loading();
|
|
|
|
private Loading() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
private ViewState() {
|
|
}
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetGuildWelcomeSheetViewModel(long j, Observable<StoreState> observable) {
|
|
super(ViewState.Loading.INSTANCE);
|
|
m.checkNotNullParameter(observable, "storeObservable");
|
|
this.guildId = j;
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(observable, this, null, 2, null), WidgetGuildWelcomeSheetViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
companion.getGuildWelcomeScreens().fetchIfNonexisting(j);
|
|
companion.getGuildWelcomeScreens().markWelcomeScreenShown(j);
|
|
AnalyticsTracker.openModal("Guild Welcome Screen", "", Long.valueOf(j));
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ WidgetGuildWelcomeSheetViewModel(long j, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, (i & 2) != 0 ? Companion.observeStores(j) : observable);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(WidgetGuildWelcomeSheetViewModel widgetGuildWelcomeSheetViewModel, StoreState storeState) {
|
|
widgetGuildWelcomeSheetViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
private final void handleLoadedGuild(Guild guild, GuildWelcomeScreen guildWelcomeScreen) {
|
|
long id2 = guild.getId();
|
|
String name = guild.getName();
|
|
String shortName = guild.getShortName();
|
|
String icon = guild.getIcon();
|
|
List<GuildWelcomeChannel> list = null;
|
|
String a = guildWelcomeScreen != null ? guildWelcomeScreen.a() : null;
|
|
if (guildWelcomeScreen != null) {
|
|
list = guildWelcomeScreen.b();
|
|
}
|
|
updateViewState(new ViewState.Loaded(id2, name, shortName, icon, a, list));
|
|
}
|
|
|
|
private final void handleLoadedWelcomeScreen(Guild guild, GuildWelcomeScreen guildWelcomeScreen) {
|
|
updateViewState(new ViewState.Loaded(guild.getId(), guild.getName(), guild.getShortName(), guild.getIcon(), guildWelcomeScreen.a(), guildWelcomeScreen.b()));
|
|
}
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
Guild component1 = storeState.component1();
|
|
StoreGuildWelcomeScreens.State component2 = storeState.component2();
|
|
GuildWelcomeScreen guildWelcomeScreen = null;
|
|
StoreGuildWelcomeScreens.State.Loaded loaded = (StoreGuildWelcomeScreens.State.Loaded) (!(component2 instanceof StoreGuildWelcomeScreens.State.Loaded) ? null : component2);
|
|
if (component1 != null && component2 == StoreGuildWelcomeScreens.State.Failure.INSTANCE) {
|
|
updateViewState(ViewState.Invalid.INSTANCE);
|
|
} else if (component2 == StoreGuildWelcomeScreens.State.Fetching.INSTANCE) {
|
|
updateViewState(ViewState.Loading.INSTANCE);
|
|
} else {
|
|
if (component1 != null) {
|
|
if ((loaded != null ? loaded.getData() : null) != null) {
|
|
handleLoadedWelcomeScreen(component1, loaded.getData());
|
|
return;
|
|
}
|
|
}
|
|
if (component1 != null) {
|
|
if (loaded != null) {
|
|
guildWelcomeScreen = loaded.getData();
|
|
}
|
|
handleLoadedGuild(component1, guildWelcomeScreen);
|
|
return;
|
|
}
|
|
if (loaded != null) {
|
|
guildWelcomeScreen = loaded.getData();
|
|
}
|
|
if (guildWelcomeScreen == null) {
|
|
updateViewState(ViewState.Invalid.INSTANCE);
|
|
} else {
|
|
updateViewState(ViewState.Loading.INSTANCE);
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void onClickChannel(long j, long j2, int i, List<GuildWelcomeChannel> list) {
|
|
m.checkNotNullParameter(list, "welcomeChannels");
|
|
ChannelSelector.selectChannel$default(ChannelSelector.Companion.getInstance(), j, j2, null, null, 12, null);
|
|
String b2 = list.get(i).b();
|
|
boolean z2 = list.get(i).c() != null;
|
|
ArrayList arrayList = new ArrayList();
|
|
ArrayList arrayList2 = new ArrayList();
|
|
for (GuildWelcomeChannel guildWelcomeChannel : list) {
|
|
arrayList2.add(Long.valueOf(guildWelcomeChannel.a()));
|
|
arrayList.add(guildWelcomeChannel.b());
|
|
}
|
|
AnalyticsTracker.welcomeScreenChannelSelected(i, j, arrayList, arrayList2, b2, z2);
|
|
}
|
|
}
|