257 lines
13 KiB
Java
257 lines
13 KiB
Java
package com.discord.widgets.stage.start;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.StringRes;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StorePermissions;
|
|
import com.discord.stores.StoreStageInstances;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.widgets.stage.discovery.StageDiscoveryAnalyticsTracker;
|
|
import com.discord.widgets.stage.start.StartStageServerSelectionItem;
|
|
import d0.t.n;
|
|
import d0.t.o;
|
|
import d0.z.d.k;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.Pair;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: StartStageServerSelectionViewModel.kt */
|
|
public final class StartStageServerSelectionViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final List<StartStageServerSelectionItem> bulletItems;
|
|
|
|
/* compiled from: StartStageServerSelectionViewModel.kt */
|
|
/* renamed from: com.discord.widgets.stage.start.StartStageServerSelectionViewModel$1 reason: invalid class name */
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<StoreState, Unit> {
|
|
public AnonymousClass1(StartStageServerSelectionViewModel startStageServerSelectionViewModel) {
|
|
super(1, startStageServerSelectionViewModel, StartStageServerSelectionViewModel.class, "handleStoreStore", "handleStoreStore(Lcom/discord/widgets/stage/start/StartStageServerSelectionViewModel$StoreState;)V", 0);
|
|
}
|
|
|
|
/* 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, "p1");
|
|
StartStageServerSelectionViewModel.access$handleStoreStore((StartStageServerSelectionViewModel) this.receiver, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: StartStageServerSelectionViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, StoreGuilds storeGuilds, StoreChannels storeChannels, StorePermissions storePermissions, StoreStageInstances storeStageInstances) {
|
|
return companion.observeStoreState(storeGuilds, storeChannels, storePermissions, storeStageInstances);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStoreState(StoreGuilds storeGuilds, StoreChannels storeChannels, StorePermissions storePermissions, StoreStageInstances storeStageInstances) {
|
|
Observable<StoreState> h = Observable.h(storeGuilds.observeGuilds(), StoreChannels.observeIds$default(storeChannels, false, 1, null), storePermissions.observeAllPermissions(), storeStageInstances.observeStageInstances(), new StartStageServerSelectionViewModel$Companion$observeStoreState$1(storeChannels));
|
|
m.checkNotNullExpressionValue(h, "Observable.combineLatest… }\n })\n }");
|
|
return h;
|
|
}
|
|
}
|
|
|
|
/* compiled from: StartStageServerSelectionViewModel.kt */
|
|
public static final class StoreState {
|
|
private final List<Pair<Guild, Channel>> guildChannelPairs;
|
|
|
|
public StoreState(List<Pair<Guild, Channel>> list) {
|
|
m.checkNotNullParameter(list, "guildChannelPairs");
|
|
this.guildChannelPairs = list;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.stage.start.StartStageServerSelectionViewModel$StoreState */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, List list, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
list = storeState.guildChannelPairs;
|
|
}
|
|
return storeState.copy(list);
|
|
}
|
|
|
|
public final List<Pair<Guild, Channel>> component1() {
|
|
return this.guildChannelPairs;
|
|
}
|
|
|
|
public final StoreState copy(List<Pair<Guild, Channel>> list) {
|
|
m.checkNotNullParameter(list, "guildChannelPairs");
|
|
return new StoreState(list);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof StoreState) && m.areEqual(this.guildChannelPairs, ((StoreState) obj).guildChannelPairs);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final List<Pair<Guild, Channel>> getGuildChannelPairs() {
|
|
return this.guildChannelPairs;
|
|
}
|
|
|
|
public int hashCode() {
|
|
List<Pair<Guild, Channel>> list = this.guildChannelPairs;
|
|
if (list != null) {
|
|
return list.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
return a.D(a.K("StoreState(guildChannelPairs="), this.guildChannelPairs, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: StartStageServerSelectionViewModel.kt */
|
|
public static final class ViewState {
|
|
private final List<StartStageServerSelectionItem> listItems;
|
|
private final int titleRes;
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: java.util.List<? extends com.discord.widgets.stage.start.StartStageServerSelectionItem> */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public ViewState(@StringRes int i, List<? extends StartStageServerSelectionItem> list) {
|
|
m.checkNotNullParameter(list, "listItems");
|
|
this.titleRes = i;
|
|
this.listItems = list;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.stage.start.StartStageServerSelectionViewModel$ViewState */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ ViewState copy$default(ViewState viewState, int i, List list, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
i = viewState.titleRes;
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
list = viewState.listItems;
|
|
}
|
|
return viewState.copy(i, list);
|
|
}
|
|
|
|
public final int component1() {
|
|
return this.titleRes;
|
|
}
|
|
|
|
public final List<StartStageServerSelectionItem> component2() {
|
|
return this.listItems;
|
|
}
|
|
|
|
public final ViewState copy(@StringRes int i, List<? extends StartStageServerSelectionItem> list) {
|
|
m.checkNotNullParameter(list, "listItems");
|
|
return new ViewState(i, list);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ViewState)) {
|
|
return false;
|
|
}
|
|
ViewState viewState = (ViewState) obj;
|
|
return this.titleRes == viewState.titleRes && m.areEqual(this.listItems, viewState.listItems);
|
|
}
|
|
|
|
public final List<StartStageServerSelectionItem> getListItems() {
|
|
return this.listItems;
|
|
}
|
|
|
|
public final int getTitleRes() {
|
|
return this.titleRes;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int i = this.titleRes * 31;
|
|
List<StartStageServerSelectionItem> list = this.listItems;
|
|
return i + (list != null ? list.hashCode() : 0);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ViewState(titleRes=");
|
|
K.append(this.titleRes);
|
|
K.append(", listItems=");
|
|
return a.D(K, this.listItems, ")");
|
|
}
|
|
}
|
|
|
|
static {
|
|
StartStageServerSelectionItem.ItemPosition itemPosition = StartStageServerSelectionItem.ItemPosition.Middle;
|
|
bulletItems = n.listOf((Object[]) new StartStageServerSelectionItem.BulletItem[]{new StartStageServerSelectionItem.BulletItem(2131231723, 2131893669, StartStageServerSelectionItem.ItemPosition.Top, 0, null, 24, null), new StartStageServerSelectionItem.BulletItem(2131231493, 2131893670, itemPosition, 0, null, 24, null), new StartStageServerSelectionItem.BulletItem(2131232088, 2131893671, itemPosition, 0, null, 24, null), new StartStageServerSelectionItem.BulletItem(2131231906, 2131893672, StartStageServerSelectionItem.ItemPosition.Bottom, 0, null, 24, null)});
|
|
}
|
|
|
|
public StartStageServerSelectionViewModel() {
|
|
this(null, null, null, null, null, 31, null);
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public StartStageServerSelectionViewModel(StoreGuilds storeGuilds, StoreChannels storeChannels, StorePermissions storePermissions, StoreStageInstances storeStageInstances, Observable<StoreState> observable) {
|
|
super(null, 1, null);
|
|
m.checkNotNullParameter(storeGuilds, "guildsStore");
|
|
m.checkNotNullParameter(storeChannels, "channelsStore");
|
|
m.checkNotNullParameter(storePermissions, "permissionsStore");
|
|
m.checkNotNullParameter(storeStageInstances, "stageInstancesStore");
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), StartStageServerSelectionViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
}
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public /* synthetic */ StartStageServerSelectionViewModel(StoreGuilds storeGuilds, StoreChannels storeChannels, StorePermissions storePermissions, StoreStageInstances storeStageInstances, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(storeGuilds, storeChannels, storePermissions, storeStageInstances, (i & 16) != 0 ? Companion.access$observeStoreState(Companion, storeGuilds, storeChannels, storePermissions, storeStageInstances) : observable);
|
|
storeGuilds = (i & 1) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds;
|
|
storeChannels = (i & 2) != 0 ? StoreStream.Companion.getChannels() : storeChannels;
|
|
storePermissions = (i & 4) != 0 ? StoreStream.Companion.getPermissions() : storePermissions;
|
|
storeStageInstances = (i & 8) != 0 ? StoreStream.Companion.getStageInstances() : storeStageInstances;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreStore(StartStageServerSelectionViewModel startStageServerSelectionViewModel, StoreState storeState) {
|
|
startStageServerSelectionViewModel.handleStoreStore(storeState);
|
|
}
|
|
|
|
private final void handleStoreStore(StoreState storeState) {
|
|
List<StartStageServerSelectionItem> list;
|
|
boolean z2 = !storeState.getGuildChannelPairs().isEmpty();
|
|
if (getViewState() == null) {
|
|
StageDiscoveryAnalyticsTracker.INSTANCE.trackStageDiscoveryStartStageClicked(z2);
|
|
}
|
|
int i = !z2 ? 2131893675 : 2131893677;
|
|
if (!z2) {
|
|
list = bulletItems;
|
|
} else {
|
|
List<Pair<Guild, Channel>> guildChannelPairs = storeState.getGuildChannelPairs();
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(guildChannelPairs, 10));
|
|
int i2 = 0;
|
|
for (Object obj : guildChannelPairs) {
|
|
int i3 = i2 + 1;
|
|
if (i2 < 0) {
|
|
n.throwIndexOverflow();
|
|
}
|
|
Pair pair = (Pair) obj;
|
|
arrayList.add(new StartStageServerSelectionItem.GuildItem((Guild) pair.component1(), (Channel) pair.component2(), (i2 == 0 && storeState.getGuildChannelPairs().size() == 1) ? StartStageServerSelectionItem.ItemPosition.Only : i2 == 0 ? StartStageServerSelectionItem.ItemPosition.Top : i2 == storeState.getGuildChannelPairs().size() - 1 ? StartStageServerSelectionItem.ItemPosition.Bottom : StartStageServerSelectionItem.ItemPosition.Middle, 0, null, 24, null));
|
|
i2 = i3;
|
|
}
|
|
list = arrayList;
|
|
}
|
|
updateViewState(new ViewState(i, list));
|
|
}
|
|
}
|