2021-11-24 07:22:14 +00:00
|
|
|
package com.discord.widgets.guilds.invite;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import androidx.annotation.MainThread;
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.discord.app.AppComponent;
|
|
|
|
import com.discord.app.AppViewModel;
|
|
|
|
import com.discord.models.domain.ModelInvite;
|
|
|
|
import com.discord.stores.StoreInstantInvites;
|
|
|
|
import com.discord.stores.StoreInviteSettings;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import d0.z.d.o;
|
2021-12-02 18:53:44 +00:00
|
|
|
import j0.l.e.k;
|
2021-11-24 07:22:14 +00:00
|
|
|
import kotlin.Unit;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import rx.Observable;
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public final class GuildInviteViewModel extends AppViewModel<ViewState> implements AppComponent {
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
private final StoreInstantInvites instantInvitesStore;
|
|
|
|
private final StoreInviteSettings.InviteCode inviteCode;
|
|
|
|
private boolean inviteResolved;
|
|
|
|
private final Observable<StoreState> storeStateObservable;
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
/* renamed from: com.discord.widgets.guilds.invite.GuildInviteViewModel$1 reason: invalid class name */
|
|
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
|
|
public final /* synthetic */ GuildInviteViewModel this$0;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public AnonymousClass1(GuildInviteViewModel guildInviteViewModel) {
|
|
|
|
super(1);
|
|
|
|
this.this$0 = guildInviteViewModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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");
|
|
|
|
GuildInviteViewModel.access$handleStoreState(this.this$0, storeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, StoreInstantInvites storeInstantInvites, StoreInviteSettings.InviteCode inviteCode) {
|
|
|
|
return companion.observeStoreState(storeInstantInvites, inviteCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final Observable<StoreState> observeStoreState(StoreInstantInvites storeInstantInvites, StoreInviteSettings.InviteCode inviteCode) {
|
|
|
|
if (inviteCode == null) {
|
2021-12-02 18:53:44 +00:00
|
|
|
k kVar = new k(StoreState.Invalid.INSTANCE);
|
|
|
|
m.checkNotNullExpressionValue(kVar, "Observable.just(StoreState.Invalid)");
|
|
|
|
return kVar;
|
2021-11-24 07:22:14 +00:00
|
|
|
}
|
|
|
|
Observable<R> F = storeInstantInvites.observeInvite(ModelInvite.getInviteStoreKey(inviteCode.getInviteCode(), inviteCode.getEventId())).F(GuildInviteViewModel$Companion$observeStoreState$1.INSTANCE);
|
|
|
|
m.checkNotNullExpressionValue(F, "instantInvitesStore\n … }\n }");
|
|
|
|
return F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static abstract class StoreState {
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static final class Invalid extends StoreState {
|
|
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
|
|
|
|
private Invalid() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static final class Loaded extends StoreState {
|
|
|
|
private final ModelInvite invite;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public Loaded(ModelInvite modelInvite) {
|
|
|
|
super(null);
|
|
|
|
m.checkNotNullParameter(modelInvite, "invite");
|
|
|
|
this.invite = modelInvite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, ModelInvite modelInvite, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
modelInvite = loaded.invite;
|
|
|
|
}
|
|
|
|
return loaded.copy(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite component1() {
|
|
|
|
return this.invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Loaded copy(ModelInvite modelInvite) {
|
|
|
|
m.checkNotNullParameter(modelInvite, "invite");
|
|
|
|
return new Loaded(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this != obj) {
|
|
|
|
return (obj instanceof Loaded) && m.areEqual(this.invite, ((Loaded) obj).invite);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite getInvite() {
|
|
|
|
return this.invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
ModelInvite modelInvite = this.invite;
|
|
|
|
if (modelInvite != null) {
|
|
|
|
return modelInvite.hashCode();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder R = a.R("Loaded(invite=");
|
|
|
|
R.append(this.invite);
|
|
|
|
R.append(")");
|
|
|
|
return R.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static final class Loading extends StoreState {
|
|
|
|
public static final Loading INSTANCE = new Loading();
|
|
|
|
|
|
|
|
private Loading() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private StoreState() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ StoreState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static abstract class ViewState {
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static final class Invalid extends ViewState {
|
|
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
|
|
|
|
private Invalid() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static final class Loaded extends ViewState {
|
|
|
|
private final ModelInvite invite;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public Loaded(ModelInvite modelInvite) {
|
|
|
|
super(null);
|
|
|
|
m.checkNotNullParameter(modelInvite, "invite");
|
|
|
|
this.invite = modelInvite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, ModelInvite modelInvite, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
modelInvite = loaded.invite;
|
|
|
|
}
|
|
|
|
return loaded.copy(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite component1() {
|
|
|
|
return this.invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Loaded copy(ModelInvite modelInvite) {
|
|
|
|
m.checkNotNullParameter(modelInvite, "invite");
|
|
|
|
return new Loaded(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this != obj) {
|
|
|
|
return (obj instanceof Loaded) && m.areEqual(this.invite, ((Loaded) obj).invite);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite getInvite() {
|
|
|
|
return this.invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
ModelInvite modelInvite = this.invite;
|
|
|
|
if (modelInvite != null) {
|
|
|
|
return modelInvite.hashCode();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder R = a.R("Loaded(invite=");
|
|
|
|
R.append(this.invite);
|
|
|
|
R.append(")");
|
|
|
|
return R.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static final class Loading extends ViewState {
|
|
|
|
public static final Loading INSTANCE = new Loading();
|
|
|
|
|
|
|
|
private Loading() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteViewModel.kt */
|
|
|
|
public static final class Uninitialized extends ViewState {
|
|
|
|
public static final Uninitialized INSTANCE = new Uninitialized();
|
|
|
|
|
|
|
|
private Uninitialized() {
|
|
|
|
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 GuildInviteViewModel(StoreInviteSettings.InviteCode inviteCode, StoreInstantInvites storeInstantInvites, Observable<StoreState> observable) {
|
|
|
|
super(ViewState.Uninitialized.INSTANCE);
|
|
|
|
m.checkNotNullParameter(storeInstantInvites, "instantInvitesStore");
|
|
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
|
|
this.inviteCode = inviteCode;
|
|
|
|
this.instantInvitesStore = storeInstantInvites;
|
|
|
|
this.storeStateObservable = observable;
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), GuildInviteViewModel.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 */ GuildInviteViewModel(StoreInviteSettings.InviteCode inviteCode, StoreInstantInvites storeInstantInvites, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this(inviteCode, storeInstantInvites, (i & 4) != 0 ? Companion.access$observeStoreState(Companion, storeInstantInvites, inviteCode) : observable);
|
|
|
|
storeInstantInvites = (i & 2) != 0 ? StoreStream.Companion.getInstantInvites() : storeInstantInvites;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(GuildInviteViewModel guildInviteViewModel, StoreState storeState) {
|
|
|
|
guildInviteViewModel.handleStoreState(storeState);
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
|
|
if (storeState instanceof StoreState.Loading) {
|
|
|
|
updateViewState(ViewState.Loading.INSTANCE);
|
|
|
|
} else if (storeState instanceof StoreState.Invalid) {
|
|
|
|
updateViewState(ViewState.Invalid.INSTANCE);
|
|
|
|
} else if (storeState instanceof StoreState.Loaded) {
|
|
|
|
updateViewState(new ViewState.Loaded(((StoreState.Loaded) storeState).getInvite()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void fetchInviteIfNotLoaded() {
|
|
|
|
if (this.inviteCode != null) {
|
|
|
|
StoreStream.Companion.getInstantInvites().fetchInviteIfNotLoaded(this.inviteCode.getInviteCode(), this.inviteCode.getEventId(), this.inviteCode.getSource(), Boolean.valueOf(this.inviteResolved), new GuildInviteViewModel$fetchInviteIfNotLoaded$1(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final StoreInviteSettings.InviteCode getInviteCode() {
|
|
|
|
return this.inviteCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean getInviteResolved() {
|
|
|
|
return this.inviteResolved;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Observable<StoreState> getStoreStateObservable() {
|
|
|
|
return this.storeStateObservable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setInviteResolved(boolean z2) {
|
|
|
|
this.inviteResolved = z2;
|
|
|
|
}
|
|
|
|
}
|