discord-jadx/app/src/main/java/com/discord/widgets/chat/list/PublishActionDialogViewMode...

331 lines
14 KiB
Java

package com.discord.widgets.chat.list;
import android.content.Context;
import c.d.b.a.a;
import com.discord.app.AppViewModel;
import com.discord.models.domain.ModelChannelFollowerStats;
import com.discord.stores.StoreChannelFollowerStats;
import com.discord.stores.StoreStream;
import com.discord.utilities.rest.RestAPI;
import com.discord.utilities.rx.ObservableExtensionsKt;
import d0.z.d.m;
import d0.z.d.o;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
import rx.subjects.PublishSubject;
/* compiled from: PublishActionDialogViewModel.kt */
public final class PublishActionDialogViewModel extends AppViewModel<ViewState> {
public static final Companion Companion = new Companion(null);
private final long channelId;
private final PublishSubject<Event> eventSubject;
private final long messageId;
private final RestAPI restAPI;
/* compiled from: PublishActionDialogViewModel.kt */
/* renamed from: com.discord.widgets.chat.list.PublishActionDialogViewModel$1 reason: invalid class name */
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
public final /* synthetic */ PublishActionDialogViewModel this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1(PublishActionDialogViewModel publishActionDialogViewModel) {
super(1);
this.this$0 = publishActionDialogViewModel;
}
/* 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");
PublishActionDialogViewModel.access$handleStoreState(this.this$0, storeState);
}
}
/* compiled from: PublishActionDialogViewModel.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ Observable access$observeChannelFollowerStatsStoreState(Companion companion, long j, StoreChannelFollowerStats storeChannelFollowerStats) {
return companion.observeChannelFollowerStatsStoreState(j, storeChannelFollowerStats);
}
private final Observable<StoreState> observeChannelFollowerStatsStoreState(long j, StoreChannelFollowerStats storeChannelFollowerStats) {
Observable<StoreState> r = storeChannelFollowerStats.observeChannelFollowerStats(j).F(PublishActionDialogViewModel$Companion$observeChannelFollowerStatsStoreState$1.INSTANCE).r();
m.checkNotNullExpressionValue(r, "storeChannelFollowerStat… .distinctUntilChanged()");
return r;
}
}
/* compiled from: PublishActionDialogViewModel.kt */
public static abstract class Event {
/* compiled from: PublishActionDialogViewModel.kt */
public static final class Failure extends Event {
private final int failureMessageStringRes;
public Failure(int i) {
super(null);
this.failureMessageStringRes = i;
}
public static /* synthetic */ Failure copy$default(Failure failure, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = failure.failureMessageStringRes;
}
return failure.copy(i);
}
public final int component1() {
return this.failureMessageStringRes;
}
public final Failure copy(int i) {
return new Failure(i);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof Failure) && this.failureMessageStringRes == ((Failure) obj).failureMessageStringRes;
}
return true;
}
public final int getFailureMessageStringRes() {
return this.failureMessageStringRes;
}
public int hashCode() {
return this.failureMessageStringRes;
}
public String toString() {
return a.z(a.L("Failure(failureMessageStringRes="), this.failureMessageStringRes, ")");
}
}
/* compiled from: PublishActionDialogViewModel.kt */
public static final class Success extends Event {
private final int successMessageStringRes;
public Success(int i) {
super(null);
this.successMessageStringRes = i;
}
public static /* synthetic */ Success copy$default(Success success, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = success.successMessageStringRes;
}
return success.copy(i);
}
public final int component1() {
return this.successMessageStringRes;
}
public final Success copy(int i) {
return new Success(i);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof Success) && this.successMessageStringRes == ((Success) obj).successMessageStringRes;
}
return true;
}
public final int getSuccessMessageStringRes() {
return this.successMessageStringRes;
}
public int hashCode() {
return this.successMessageStringRes;
}
public String toString() {
return a.z(a.L("Success(successMessageStringRes="), this.successMessageStringRes, ")");
}
}
private Event() {
}
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: PublishActionDialogViewModel.kt */
public static final class StoreState {
private final ModelChannelFollowerStats followerStats;
public StoreState(ModelChannelFollowerStats modelChannelFollowerStats) {
this.followerStats = modelChannelFollowerStats;
}
public final ModelChannelFollowerStats getFollowerStats() {
return this.followerStats;
}
}
/* compiled from: PublishActionDialogViewModel.kt */
public static abstract class ViewState {
/* compiled from: PublishActionDialogViewModel.kt */
public static final class LoadedHasFollowers extends ViewState {
private final ModelChannelFollowerStats followerStats;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public LoadedHasFollowers(ModelChannelFollowerStats modelChannelFollowerStats) {
super(null);
m.checkNotNullParameter(modelChannelFollowerStats, "followerStats");
this.followerStats = modelChannelFollowerStats;
}
public static /* synthetic */ LoadedHasFollowers copy$default(LoadedHasFollowers loadedHasFollowers, ModelChannelFollowerStats modelChannelFollowerStats, int i, Object obj) {
if ((i & 1) != 0) {
modelChannelFollowerStats = loadedHasFollowers.followerStats;
}
return loadedHasFollowers.copy(modelChannelFollowerStats);
}
public final ModelChannelFollowerStats component1() {
return this.followerStats;
}
public final LoadedHasFollowers copy(ModelChannelFollowerStats modelChannelFollowerStats) {
m.checkNotNullParameter(modelChannelFollowerStats, "followerStats");
return new LoadedHasFollowers(modelChannelFollowerStats);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof LoadedHasFollowers) && m.areEqual(this.followerStats, ((LoadedHasFollowers) obj).followerStats);
}
return true;
}
public final ModelChannelFollowerStats getFollowerStats() {
return this.followerStats;
}
public int hashCode() {
ModelChannelFollowerStats modelChannelFollowerStats = this.followerStats;
if (modelChannelFollowerStats != null) {
return modelChannelFollowerStats.hashCode();
}
return 0;
}
public String toString() {
StringBuilder L = a.L("LoadedHasFollowers(followerStats=");
L.append(this.followerStats);
L.append(")");
return L.toString();
}
}
/* compiled from: PublishActionDialogViewModel.kt */
public static final class LoadedNoFollowers extends ViewState {
public static final LoadedNoFollowers INSTANCE = new LoadedNoFollowers();
private LoadedNoFollowers() {
super(null);
}
}
/* compiled from: PublishActionDialogViewModel.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 PublishActionDialogViewModel(long j, long j2, RestAPI restAPI, StoreChannelFollowerStats storeChannelFollowerStats, Observable<StoreState> observable) {
super(ViewState.Loading.INSTANCE);
m.checkNotNullParameter(restAPI, "restAPI");
m.checkNotNullParameter(storeChannelFollowerStats, "storeChannelFollowerStats");
m.checkNotNullParameter(observable, "storeObservable");
this.messageId = j;
this.channelId = j2;
this.restAPI = restAPI;
this.eventSubject = PublishSubject.k0();
storeChannelFollowerStats.fetchChannelFollowerStats(j2);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), PublishActionDialogViewModel.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 */ PublishActionDialogViewModel(long j, long j2, RestAPI restAPI, StoreChannelFollowerStats storeChannelFollowerStats, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(j, j2, r6, r7, (i & 16) != 0 ? Companion.access$observeChannelFollowerStatsStoreState(Companion, j2, r7) : observable);
RestAPI api = (i & 4) != 0 ? RestAPI.Companion.getApi() : restAPI;
StoreChannelFollowerStats channelFollowerStats = (i & 8) != 0 ? StoreStream.Companion.getChannelFollowerStats() : storeChannelFollowerStats;
}
public static final /* synthetic */ void access$emitFailureEvent(PublishActionDialogViewModel publishActionDialogViewModel) {
publishActionDialogViewModel.emitFailureEvent();
}
public static final /* synthetic */ void access$emitSuccessActionEvent(PublishActionDialogViewModel publishActionDialogViewModel) {
publishActionDialogViewModel.emitSuccessActionEvent();
}
public static final /* synthetic */ void access$handleStoreState(PublishActionDialogViewModel publishActionDialogViewModel, StoreState storeState) {
publishActionDialogViewModel.handleStoreState(storeState);
}
private final void emitFailureEvent() {
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.j.onNext(new Event.Failure(2131888048));
}
private final void emitSuccessActionEvent() {
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.j.onNext(new Event.Success(2131891239));
}
private final void handleStoreState(StoreState storeState) {
Integer guildsFollowing;
ModelChannelFollowerStats followerStats = storeState.getFollowerStats();
int intValue = (followerStats == null || (guildsFollowing = followerStats.getGuildsFollowing()) == null) ? 0 : guildsFollowing.intValue();
if ((followerStats != null ? followerStats.getGuildsFollowing() : null) == null || intValue <= 0) {
updateViewState(ViewState.LoadedNoFollowers.INSTANCE);
} else {
updateViewState(new ViewState.LoadedHasFollowers(followerStats));
}
}
public final Observable<Event> observeEvents() {
PublishSubject<Event> publishSubject = this.eventSubject;
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
return publishSubject;
}
public final void publishMessage() {
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(this.restAPI.crosspostMessage(this.channelId, Long.valueOf(this.messageId)), false, 1, null), this, null, 2, null), PublishActionDialogViewModel.class, (Context) null, (Function1) null, new PublishActionDialogViewModel$publishMessage$2(this), (Function0) null, (Function0) null, new PublishActionDialogViewModel$publishMessage$1(this), 54, (Object) null);
}
}