122 lines
6.5 KiB
Java
122 lines
6.5 KiB
Java
package com.discord.widgets.hubs;
|
|
|
|
import android.content.Context;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreChannelsSelected;
|
|
import com.discord.stores.StoreDirectories;
|
|
import com.discord.stores.StoreGuildSelected;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StorePermissions;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import d0.z.d.k;
|
|
import d0.z.d.m;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetHubAddServerViewModel.kt */
|
|
/* loaded from: classes2.dex */
|
|
public final class WidgetHubAddServerViewModel extends AppViewModel<HubAddServerState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
/* compiled from: WidgetHubAddServerViewModel.kt */
|
|
/* renamed from: com.discord.widgets.hubs.WidgetHubAddServerViewModel$1 reason: invalid class name */
|
|
/* loaded from: classes2.dex */
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<HubAddServerState, Unit> {
|
|
public AnonymousClass1(WidgetHubAddServerViewModel widgetHubAddServerViewModel) {
|
|
super(1, widgetHubAddServerViewModel, WidgetHubAddServerViewModel.class, "handleStoreUpdate", "handleStoreUpdate(Lcom/discord/widgets/hubs/HubAddServerState;)V", 0);
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(HubAddServerState hubAddServerState) {
|
|
invoke2(hubAddServerState);
|
|
return Unit.a;
|
|
}
|
|
|
|
/* renamed from: invoke reason: avoid collision after fix types in other method */
|
|
public final void invoke2(HubAddServerState hubAddServerState) {
|
|
m.checkNotNullParameter(hubAddServerState, "p1");
|
|
WidgetHubAddServerViewModel.access$handleStoreUpdate((WidgetHubAddServerViewModel) this.receiver, hubAddServerState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetHubAddServerViewModel.kt */
|
|
/* loaded from: classes2.dex */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStores(Companion companion, ObservationDeck observationDeck, StoreGuilds storeGuilds, StoreGuildSelected storeGuildSelected, StorePermissions storePermissions, StoreChannels storeChannels, StoreChannelsSelected storeChannelsSelected, StoreDirectories storeDirectories) {
|
|
return companion.observeStores(observationDeck, storeGuilds, storeGuildSelected, storePermissions, storeChannels, storeChannelsSelected, storeDirectories);
|
|
}
|
|
|
|
private final Observable<HubAddServerState> observeStores(ObservationDeck observationDeck, StoreGuilds storeGuilds, StoreGuildSelected storeGuildSelected, StorePermissions storePermissions, StoreChannels storeChannels, StoreChannelsSelected storeChannelsSelected, StoreDirectories storeDirectories) {
|
|
return ObservationDeck.connectRx$default(observationDeck, new ObservationDeck.UpdateSource[]{storeGuilds, storeGuildSelected, storePermissions, storeChannels, storeChannelsSelected, storeDirectories}, false, null, null, new WidgetHubAddServerViewModel$Companion$observeStores$1(storeGuilds, storeGuildSelected, storePermissions, storeChannelsSelected, storeChannels, storeDirectories), 14, null);
|
|
}
|
|
}
|
|
|
|
public WidgetHubAddServerViewModel() {
|
|
this(null, 1, null);
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public WidgetHubAddServerViewModel(Observable<HubAddServerState> observable) {
|
|
super(new HubAddServerState(null, null, 0, null, null, null, 63, null));
|
|
m.checkNotNullParameter(observable, "storeObservable");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), WidgetHubAddServerViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
}
|
|
|
|
/* JADX WARN: Illegal instructions before constructor call */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
*/
|
|
public /* synthetic */ WidgetHubAddServerViewModel(Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(observable);
|
|
if ((i & 1) != 0) {
|
|
Companion companion = Companion;
|
|
ObservationDeck observationDeck = ObservationDeckProvider.get();
|
|
StoreStream.Companion companion2 = StoreStream.Companion;
|
|
observable = Companion.access$observeStores(companion, observationDeck, companion2.getGuilds(), companion2.getGuildSelected(), companion2.getPermissions(), companion2.getChannels(), companion2.getChannelsSelected(), companion2.getDirectories());
|
|
}
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreUpdate(WidgetHubAddServerViewModel widgetHubAddServerViewModel, HubAddServerState hubAddServerState) {
|
|
widgetHubAddServerViewModel.handleStoreUpdate(hubAddServerState);
|
|
}
|
|
|
|
private final void handleStoreUpdate(HubAddServerState hubAddServerState) {
|
|
updateViewState(HubAddServerState.copy$default(requireViewState(), hubAddServerState.getHubName(), hubAddServerState.getDirectoryChannelId(), 0, hubAddServerState.getSelectableGuilds(), hubAddServerState.getAddedGuilds(), hubAddServerState.getAddedDirectories(), 4, null));
|
|
}
|
|
|
|
public final Long getChannelId() {
|
|
HubAddServerState viewState = getViewState();
|
|
if (viewState != null) {
|
|
return viewState.getDirectoryChannelId();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public final String getHubName() {
|
|
HubAddServerState viewState = getViewState();
|
|
String hubName = viewState != null ? viewState.getHubName() : null;
|
|
return hubName != null ? hubName : "";
|
|
}
|
|
|
|
public final void removeGuild(long j, long j2) {
|
|
StoreStream.Companion.getDirectories().removeServerFromDirectory(j2, j);
|
|
}
|
|
|
|
public final void setIndex(int i) {
|
|
updateViewState(HubAddServerState.copy$default(requireViewState(), null, null, i, null, null, null, 59, null));
|
|
}
|
|
}
|