discord-jadx/app/src/main/java/com/discord/widgets/auth/WidgetAuthLandingViewModel....

572 lines
25 KiB
Java

package com.discord.widgets.auth;
import android.content.Context;
import androidx.annotation.MainThread;
import c.d.b.a.a;
import com.discord.app.AppViewModel;
import com.discord.models.domain.ModelGuildTemplate;
import com.discord.models.domain.ModelInvite;
import com.discord.stores.StoreAnalytics;
import com.discord.stores.StoreAuthentication;
import com.discord.stores.StoreGuildTemplates;
import com.discord.stores.StoreInstantInvites;
import com.discord.stores.StoreInviteSettings;
import com.discord.stores.StoreStream;
import com.discord.utilities.auth.GoogleSmartLockManager;
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: WidgetAuthLandingViewModel.kt */
public final class WidgetAuthLandingViewModel extends AppViewModel<ViewState> {
public static final Companion Companion = new Companion(null);
private final PublishSubject<Event> eventSubject;
private final GoogleSmartLockManager googleSmartLockManager;
private StoreState mostRecentStoreState;
private boolean smartLockCredentialRequestDisabled;
private final StoreInstantInvites storeInstantInvites;
/* compiled from: WidgetAuthLandingViewModel.kt */
/* renamed from: com.discord.widgets.auth.WidgetAuthLandingViewModel$1 reason: invalid class name */
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
public final /* synthetic */ WidgetAuthLandingViewModel this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1(WidgetAuthLandingViewModel widgetAuthLandingViewModel) {
super(1);
this.this$0 = widgetAuthLandingViewModel;
}
/* 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, "it");
this.this$0.handleStoreState(storeState);
}
}
/* compiled from: WidgetAuthLandingViewModel.kt */
/* renamed from: com.discord.widgets.auth.WidgetAuthLandingViewModel$2 reason: invalid class name */
public static final class AnonymousClass2 extends o implements Function1<GoogleSmartLockManager.SmartLockCredentials, Unit> {
public final /* synthetic */ WidgetAuthLandingViewModel this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass2(WidgetAuthLandingViewModel widgetAuthLandingViewModel) {
super(1);
this.this$0 = widgetAuthLandingViewModel;
}
/* 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(GoogleSmartLockManager.SmartLockCredentials smartLockCredentials) {
invoke(smartLockCredentials);
return Unit.a;
}
public final void invoke(GoogleSmartLockManager.SmartLockCredentials smartLockCredentials) {
m.checkNotNullParameter(smartLockCredentials, "it");
PublishSubject access$getEventSubject$p = WidgetAuthLandingViewModel.access$getEventSubject$p(this.this$0);
access$getEventSubject$p.j.onNext(new Event.SmartLockLogin(smartLockCredentials));
}
}
/* compiled from: WidgetAuthLandingViewModel.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, StoreInviteSettings storeInviteSettings, StoreGuildTemplates storeGuildTemplates, StoreAuthentication storeAuthentication) {
return companion.observeStoreState(storeInviteSettings, storeGuildTemplates, storeAuthentication);
}
private final Observable<StoreState> observeStoreState(StoreInviteSettings storeInviteSettings, StoreGuildTemplates storeGuildTemplates, StoreAuthentication storeAuthentication) {
Observable<StoreState> h = Observable.h(storeInviteSettings.getInviteCode(), storeInviteSettings.getInvite(), storeGuildTemplates.observeDynamicLinkGuildTemplateCode().Y(new WidgetAuthLandingViewModel$Companion$observeStoreState$1(storeGuildTemplates)), storeAuthentication.getAgeGateError(), WidgetAuthLandingViewModel$Companion$observeStoreState$2.INSTANCE);
m.checkNotNullExpressionValue(h, "Observable.combineLatest…eError,\n )\n }");
return h;
}
}
/* compiled from: WidgetAuthLandingViewModel.kt */
public static abstract class Event {
/* compiled from: WidgetAuthLandingViewModel.kt */
public static final class SmartLockLogin extends Event {
private final GoogleSmartLockManager.SmartLockCredentials smartLockCredentials;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public SmartLockLogin(GoogleSmartLockManager.SmartLockCredentials smartLockCredentials) {
super(null);
m.checkNotNullParameter(smartLockCredentials, "smartLockCredentials");
this.smartLockCredentials = smartLockCredentials;
}
public static /* synthetic */ SmartLockLogin copy$default(SmartLockLogin smartLockLogin, GoogleSmartLockManager.SmartLockCredentials smartLockCredentials, int i, Object obj) {
if ((i & 1) != 0) {
smartLockCredentials = smartLockLogin.smartLockCredentials;
}
return smartLockLogin.copy(smartLockCredentials);
}
public final GoogleSmartLockManager.SmartLockCredentials component1() {
return this.smartLockCredentials;
}
public final SmartLockLogin copy(GoogleSmartLockManager.SmartLockCredentials smartLockCredentials) {
m.checkNotNullParameter(smartLockCredentials, "smartLockCredentials");
return new SmartLockLogin(smartLockCredentials);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof SmartLockLogin) && m.areEqual(this.smartLockCredentials, ((SmartLockLogin) obj).smartLockCredentials);
}
return true;
}
public final GoogleSmartLockManager.SmartLockCredentials getSmartLockCredentials() {
return this.smartLockCredentials;
}
public int hashCode() {
GoogleSmartLockManager.SmartLockCredentials smartLockCredentials = this.smartLockCredentials;
if (smartLockCredentials != null) {
return smartLockCredentials.hashCode();
}
return 0;
}
public String toString() {
StringBuilder K = a.K("SmartLockLogin(smartLockCredentials=");
K.append(this.smartLockCredentials);
K.append(")");
return K.toString();
}
}
private Event() {
}
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: WidgetAuthLandingViewModel.kt */
public static final class StoreState {
private final String ageGateError;
private final StoreGuildTemplates.GuildTemplateState guildTemplateState;
private final ModelInvite invite;
private final StoreInviteSettings.InviteCode inviteCode;
public StoreState(StoreInviteSettings.InviteCode inviteCode, ModelInvite modelInvite, StoreGuildTemplates.GuildTemplateState guildTemplateState, String str) {
m.checkNotNullParameter(guildTemplateState, "guildTemplateState");
this.inviteCode = inviteCode;
this.invite = modelInvite;
this.guildTemplateState = guildTemplateState;
this.ageGateError = str;
}
public static /* synthetic */ StoreState copy$default(StoreState storeState, StoreInviteSettings.InviteCode inviteCode, ModelInvite modelInvite, StoreGuildTemplates.GuildTemplateState guildTemplateState, String str, int i, Object obj) {
if ((i & 1) != 0) {
inviteCode = storeState.inviteCode;
}
if ((i & 2) != 0) {
modelInvite = storeState.invite;
}
if ((i & 4) != 0) {
guildTemplateState = storeState.guildTemplateState;
}
if ((i & 8) != 0) {
str = storeState.ageGateError;
}
return storeState.copy(inviteCode, modelInvite, guildTemplateState, str);
}
public final StoreInviteSettings.InviteCode component1() {
return this.inviteCode;
}
public final ModelInvite component2() {
return this.invite;
}
public final StoreGuildTemplates.GuildTemplateState component3() {
return this.guildTemplateState;
}
public final String component4() {
return this.ageGateError;
}
public final StoreState copy(StoreInviteSettings.InviteCode inviteCode, ModelInvite modelInvite, StoreGuildTemplates.GuildTemplateState guildTemplateState, String str) {
m.checkNotNullParameter(guildTemplateState, "guildTemplateState");
return new StoreState(inviteCode, modelInvite, guildTemplateState, str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof StoreState)) {
return false;
}
StoreState storeState = (StoreState) obj;
return m.areEqual(this.inviteCode, storeState.inviteCode) && m.areEqual(this.invite, storeState.invite) && m.areEqual(this.guildTemplateState, storeState.guildTemplateState) && m.areEqual(this.ageGateError, storeState.ageGateError);
}
public final String getAgeGateError() {
return this.ageGateError;
}
public final StoreGuildTemplates.GuildTemplateState getGuildTemplateState() {
return this.guildTemplateState;
}
public final ModelInvite getInvite() {
return this.invite;
}
public final StoreInviteSettings.InviteCode getInviteCode() {
return this.inviteCode;
}
public int hashCode() {
StoreInviteSettings.InviteCode inviteCode = this.inviteCode;
int i = 0;
int hashCode = (inviteCode != null ? inviteCode.hashCode() : 0) * 31;
ModelInvite modelInvite = this.invite;
int hashCode2 = (hashCode + (modelInvite != null ? modelInvite.hashCode() : 0)) * 31;
StoreGuildTemplates.GuildTemplateState guildTemplateState = this.guildTemplateState;
int hashCode3 = (hashCode2 + (guildTemplateState != null ? guildTemplateState.hashCode() : 0)) * 31;
String str = this.ageGateError;
if (str != null) {
i = str.hashCode();
}
return hashCode3 + i;
}
public String toString() {
StringBuilder K = a.K("StoreState(inviteCode=");
K.append(this.inviteCode);
K.append(", invite=");
K.append(this.invite);
K.append(", guildTemplateState=");
K.append(this.guildTemplateState);
K.append(", ageGateError=");
return a.C(K, this.ageGateError, ")");
}
}
/* compiled from: WidgetAuthLandingViewModel.kt */
public static abstract class ViewState {
private final String ageGateError;
/* compiled from: WidgetAuthLandingViewModel.kt */
public static final class Empty extends ViewState {
private final String ageGateError;
public Empty(String str) {
super(str, null);
this.ageGateError = str;
}
public static /* synthetic */ Empty copy$default(Empty empty, String str, int i, Object obj) {
if ((i & 1) != 0) {
str = empty.getAgeGateError();
}
return empty.copy(str);
}
public final String component1() {
return getAgeGateError();
}
public final Empty copy(String str) {
return new Empty(str);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof Empty) && m.areEqual(getAgeGateError(), ((Empty) obj).getAgeGateError());
}
return true;
}
@Override // com.discord.widgets.auth.WidgetAuthLandingViewModel.ViewState
public String getAgeGateError() {
return this.ageGateError;
}
public int hashCode() {
String ageGateError = getAgeGateError();
if (ageGateError != null) {
return ageGateError.hashCode();
}
return 0;
}
public String toString() {
StringBuilder K = a.K("Empty(ageGateError=");
K.append(getAgeGateError());
K.append(")");
return K.toString();
}
}
/* compiled from: WidgetAuthLandingViewModel.kt */
public static final class GuildTemplate extends ViewState {
private final String ageGateError;
private final ModelGuildTemplate guildTemplate;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public GuildTemplate(ModelGuildTemplate modelGuildTemplate, String str) {
super(str, null);
m.checkNotNullParameter(modelGuildTemplate, "guildTemplate");
this.guildTemplate = modelGuildTemplate;
this.ageGateError = str;
}
public static /* synthetic */ GuildTemplate copy$default(GuildTemplate guildTemplate, ModelGuildTemplate modelGuildTemplate, String str, int i, Object obj) {
if ((i & 1) != 0) {
modelGuildTemplate = guildTemplate.guildTemplate;
}
if ((i & 2) != 0) {
str = guildTemplate.getAgeGateError();
}
return guildTemplate.copy(modelGuildTemplate, str);
}
public final ModelGuildTemplate component1() {
return this.guildTemplate;
}
public final String component2() {
return getAgeGateError();
}
public final GuildTemplate copy(ModelGuildTemplate modelGuildTemplate, String str) {
m.checkNotNullParameter(modelGuildTemplate, "guildTemplate");
return new GuildTemplate(modelGuildTemplate, str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof GuildTemplate)) {
return false;
}
GuildTemplate guildTemplate = (GuildTemplate) obj;
return m.areEqual(this.guildTemplate, guildTemplate.guildTemplate) && m.areEqual(getAgeGateError(), guildTemplate.getAgeGateError());
}
@Override // com.discord.widgets.auth.WidgetAuthLandingViewModel.ViewState
public String getAgeGateError() {
return this.ageGateError;
}
public final ModelGuildTemplate getGuildTemplate() {
return this.guildTemplate;
}
public int hashCode() {
ModelGuildTemplate modelGuildTemplate = this.guildTemplate;
int i = 0;
int hashCode = (modelGuildTemplate != null ? modelGuildTemplate.hashCode() : 0) * 31;
String ageGateError = getAgeGateError();
if (ageGateError != null) {
i = ageGateError.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder K = a.K("GuildTemplate(guildTemplate=");
K.append(this.guildTemplate);
K.append(", ageGateError=");
K.append(getAgeGateError());
K.append(")");
return K.toString();
}
}
/* compiled from: WidgetAuthLandingViewModel.kt */
public static final class Invite extends ViewState {
private final String ageGateError;
private final ModelInvite invite;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Invite(ModelInvite modelInvite, String str) {
super(str, null);
m.checkNotNullParameter(modelInvite, "invite");
this.invite = modelInvite;
this.ageGateError = str;
}
public static /* synthetic */ Invite copy$default(Invite invite, ModelInvite modelInvite, String str, int i, Object obj) {
if ((i & 1) != 0) {
modelInvite = invite.invite;
}
if ((i & 2) != 0) {
str = invite.getAgeGateError();
}
return invite.copy(modelInvite, str);
}
public final ModelInvite component1() {
return this.invite;
}
public final String component2() {
return getAgeGateError();
}
public final Invite copy(ModelInvite modelInvite, String str) {
m.checkNotNullParameter(modelInvite, "invite");
return new Invite(modelInvite, str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Invite)) {
return false;
}
Invite invite = (Invite) obj;
return m.areEqual(this.invite, invite.invite) && m.areEqual(getAgeGateError(), invite.getAgeGateError());
}
@Override // com.discord.widgets.auth.WidgetAuthLandingViewModel.ViewState
public String getAgeGateError() {
return this.ageGateError;
}
public final ModelInvite getInvite() {
return this.invite;
}
public int hashCode() {
ModelInvite modelInvite = this.invite;
int i = 0;
int hashCode = (modelInvite != null ? modelInvite.hashCode() : 0) * 31;
String ageGateError = getAgeGateError();
if (ageGateError != null) {
i = ageGateError.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder K = a.K("Invite(invite=");
K.append(this.invite);
K.append(", ageGateError=");
K.append(getAgeGateError());
K.append(")");
return K.toString();
}
}
private ViewState(String str) {
this.ageGateError = str;
}
public /* synthetic */ ViewState(String str, DefaultConstructorMarker defaultConstructorMarker) {
this(str);
}
public String getAgeGateError() {
return this.ageGateError;
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public WidgetAuthLandingViewModel(Context context, StoreAuthentication storeAuthentication, StoreAnalytics storeAnalytics, Observable<StoreState> observable, StoreInstantInvites storeInstantInvites, GoogleSmartLockManager googleSmartLockManager) {
super(new ViewState.Empty(null));
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(storeAuthentication, "storeAuthentication");
m.checkNotNullParameter(storeAnalytics, "storeAnalytics");
m.checkNotNullParameter(observable, "storeObservable");
m.checkNotNullParameter(storeInstantInvites, "storeInstantInvites");
m.checkNotNullParameter(googleSmartLockManager, "googleSmartLockManager");
this.storeInstantInvites = storeInstantInvites;
this.googleSmartLockManager = googleSmartLockManager;
this.eventSubject = PublishSubject.k0();
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(observable, this, null, 2, null), WidgetAuthLandingViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(googleSmartLockManager.getSmartLockRepo().getSmartLockLoginObservable(), this, null, 2, null), WidgetAuthLandingViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass2(this), 62, (Object) null);
storeAuthentication.requestConsentRequired();
storeAnalytics.appLandingViewed();
}
/* JADX WARNING: Illegal instructions before constructor call */
public /* synthetic */ WidgetAuthLandingViewModel(Context context, StoreAuthentication storeAuthentication, StoreAnalytics storeAnalytics, Observable observable, StoreInstantInvites storeInstantInvites, GoogleSmartLockManager googleSmartLockManager, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(context, storeAuthentication, storeAnalytics, observable, (i & 16) != 0 ? StoreStream.Companion.getInstantInvites() : storeInstantInvites, (i & 32) != 0 ? new GoogleSmartLockManager(context, null, 2, null) : googleSmartLockManager);
storeAuthentication = (i & 2) != 0 ? StoreStream.Companion.getAuthentication() : storeAuthentication;
storeAnalytics = (i & 4) != 0 ? StoreStream.Companion.getAnalytics() : storeAnalytics;
if ((i & 8) != 0) {
Companion companion = Companion;
StoreStream.Companion companion2 = StoreStream.Companion;
observable = Companion.access$observeStoreState(companion, companion2.getInviteSettings(), companion2.getGuildTemplates(), companion2.getAuthentication());
}
}
public static final /* synthetic */ PublishSubject access$getEventSubject$p(WidgetAuthLandingViewModel widgetAuthLandingViewModel) {
return widgetAuthLandingViewModel.eventSubject;
}
public final GoogleSmartLockManager getGoogleSmartLockManager() {
return this.googleSmartLockManager;
}
public final boolean getSmartLockCredentialRequestDisabled() {
return this.smartLockCredentialRequestDisabled;
}
@MainThread
public final void handleStoreState(StoreState storeState) {
m.checkNotNullParameter(storeState, "storeState");
StoreInviteSettings.InviteCode inviteCode = storeState.getInviteCode();
StoreState storeState2 = this.mostRecentStoreState;
if ((!m.areEqual(storeState2 != null ? storeState2.getInviteCode() : null, inviteCode)) && inviteCode != null) {
StoreInstantInvites.fetchInviteIfNotLoaded$default(this.storeInstantInvites, inviteCode.getInviteCode(), null, 2, null);
}
ModelInvite invite = storeState.getInvite();
StoreGuildTemplates.GuildTemplateState guildTemplateState = storeState.getGuildTemplateState();
String ageGateError = storeState.getAgeGateError();
if (invite != null) {
updateViewState(new ViewState.Invite(invite, ageGateError));
} else if (guildTemplateState instanceof StoreGuildTemplates.GuildTemplateState.Resolved) {
updateViewState(new ViewState.GuildTemplate(((StoreGuildTemplates.GuildTemplateState.Resolved) guildTemplateState).getGuildTemplate(), ageGateError));
} else {
updateViewState(new ViewState.Empty(ageGateError));
}
this.mostRecentStoreState = storeState;
}
public final Observable<Event> observeEvents() {
PublishSubject<Event> publishSubject = this.eventSubject;
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
return publishSubject;
}
public final void setSmartLockCredentialRequestDisabled(boolean z2) {
this.smartLockCredentialRequestDisabled = z2;
}
}