114 lines
5.9 KiB
Java
114 lines
5.9 KiB
Java
package com.discord.widgets.hubs;
|
|
|
|
import android.content.Context;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.restapi.RestAPIParams;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreChannelsSelected;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
import com.discord.stores.utilities.RestCallStateKt;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
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: WidgetDiscordHubDescriptionViewModel.kt */
|
|
public final class WidgetDiscordHubsDescriptionViewModel extends AppViewModel<HubDescriptionState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final long guildId;
|
|
private final RestAPI restAPI;
|
|
|
|
/* compiled from: WidgetDiscordHubDescriptionViewModel.kt */
|
|
/* renamed from: com.discord.widgets.hubs.WidgetDiscordHubsDescriptionViewModel$1 reason: invalid class name */
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<HubDescriptionState, Unit> {
|
|
public AnonymousClass1(WidgetDiscordHubsDescriptionViewModel widgetDiscordHubsDescriptionViewModel) {
|
|
super(1, widgetDiscordHubsDescriptionViewModel, WidgetDiscordHubsDescriptionViewModel.class, "handleStoreState", "handleStoreState(Lcom/discord/widgets/hubs/HubDescriptionState;)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(HubDescriptionState hubDescriptionState) {
|
|
invoke(hubDescriptionState);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(HubDescriptionState hubDescriptionState) {
|
|
m.checkNotNullParameter(hubDescriptionState, "p1");
|
|
((WidgetDiscordHubsDescriptionViewModel) this.receiver).handleStoreState(hubDescriptionState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetDiscordHubDescriptionViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final Observable<HubDescriptionState> observeStores(ObservationDeck observationDeck, StoreGuilds storeGuilds, StoreChannels storeChannels, StoreChannelsSelected storeChannelsSelected, long j) {
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
m.checkNotNullParameter(storeGuilds, "guildStore");
|
|
m.checkNotNullParameter(storeChannels, "channelsStore");
|
|
m.checkNotNullParameter(storeChannelsSelected, "channelsSelectedStore");
|
|
return ObservationDeck.connectRx$default(observationDeck, new ObservationDeck.UpdateSource[]{storeGuilds, storeChannels, storeChannelsSelected}, false, null, null, new WidgetDiscordHubsDescriptionViewModel$Companion$observeStores$1(storeChannelsSelected, storeChannels, j, storeGuilds), 14, null);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetDiscordHubsDescriptionViewModel(long j, RestAPI restAPI, Observable<HubDescriptionState> observable) {
|
|
super(new HubDescriptionState(0, null, null, 7, null));
|
|
m.checkNotNullParameter(restAPI, "restAPI");
|
|
m.checkNotNullParameter(observable, "storeObservable");
|
|
this.guildId = j;
|
|
this.restAPI = restAPI;
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), WidgetDiscordHubsDescriptionViewModel.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 */ WidgetDiscordHubsDescriptionViewModel(long j, RestAPI restAPI, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, restAPI, observable);
|
|
restAPI = (i & 2) != 0 ? RestAPI.Companion.getApi() : restAPI;
|
|
if ((i & 4) != 0) {
|
|
Companion companion = Companion;
|
|
ObservationDeck observationDeck = ObservationDeckProvider.get();
|
|
StoreStream.Companion companion2 = StoreStream.Companion;
|
|
observable = companion.observeStores(observationDeck, companion2.getGuilds(), companion2.getChannels(), companion2.getChannelsSelected(), j);
|
|
}
|
|
}
|
|
|
|
public static final /* synthetic */ void access$updateViewState(WidgetDiscordHubsDescriptionViewModel widgetDiscordHubsDescriptionViewModel, HubDescriptionState hubDescriptionState) {
|
|
widgetDiscordHubsDescriptionViewModel.updateViewState(hubDescriptionState);
|
|
}
|
|
|
|
public final void addServer(String str) {
|
|
m.checkNotNullParameter(str, "description");
|
|
HubDescriptionState viewState = getViewState();
|
|
if (viewState != null) {
|
|
RestCallStateKt.executeRequest(this.restAPI.addServerToHub(viewState.getChannelId(), this.guildId, new RestAPIParams.AddServerBody(str)), new WidgetDiscordHubsDescriptionViewModel$addServer$1(this, viewState));
|
|
}
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final RestAPI getRestAPI() {
|
|
return this.restAPI;
|
|
}
|
|
|
|
public final void handleStoreState(HubDescriptionState hubDescriptionState) {
|
|
m.checkNotNullParameter(hubDescriptionState, "state");
|
|
updateViewState(hubDescriptionState);
|
|
}
|
|
}
|