798 lines
36 KiB
Java
798 lines
36 KiB
Java
package com.discord.widgets.servers.premiumguild;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import androidx.annotation.MainThread;
|
|
import androidx.annotation.StringRes;
|
|
import c.d.b.a.a;
|
|
import com.android.billingclient.api.Purchase;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.domain.ModelPremiumGuildSubscription;
|
|
import com.discord.models.domain.ModelPremiumGuildSubscriptionSlot;
|
|
import com.discord.models.domain.ModelSubscription;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.stores.StoreGooglePlayPurchases;
|
|
import com.discord.stores.StorePremiumGuildSubscription;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreSubscriptions;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.utilities.billing.GooglePlayBillingManager;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.time.Clock;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
import rx.functions.Func5;
|
|
import rx.subjects.PublishSubject;
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public final class PremiumGuildViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final Clock clock;
|
|
private final PublishSubject<Event> eventSubject;
|
|
private final long guildId;
|
|
private final StorePremiumGuildSubscription storePremiumGuildSubscription;
|
|
private final StoreSubscriptions storeSubscriptions;
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
/* renamed from: com.discord.widgets.servers.premiumguild.PremiumGuildViewModel$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
public final /* synthetic */ PremiumGuildViewModel this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(PremiumGuildViewModel premiumGuildViewModel) {
|
|
super(1);
|
|
this.this$0 = premiumGuildViewModel;
|
|
}
|
|
|
|
/* 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");
|
|
PremiumGuildViewModel.access$handleStoreState(this.this$0, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStores(Companion companion, long j) {
|
|
return companion.observeStores(j);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
private final Observable<StoreState> observeStores(long j) {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable observePremiumGuildSubscriptionsState$default = StorePremiumGuildSubscription.observePremiumGuildSubscriptionsState$default(companion.getPremiumGuildSubscriptions(), null, 1, null);
|
|
Observable<StoreSubscriptions.SubscriptionsState> observeSubscriptions = companion.getSubscriptions().observeSubscriptions();
|
|
Observable observeMe$default = StoreUser.observeMe$default(companion.getUsers(), false, 1, null);
|
|
Observable<Guild> observeGuild = companion.getGuilds().observeGuild(j);
|
|
Observable<StoreGooglePlayPurchases.State> observeState = companion.getGooglePlayPurchases().observeState();
|
|
PremiumGuildViewModel$Companion$observeStores$1 premiumGuildViewModel$Companion$observeStores$1 = PremiumGuildViewModel$Companion$observeStores$1.INSTANCE;
|
|
if (premiumGuildViewModel$Companion$observeStores$1 != null) {
|
|
premiumGuildViewModel$Companion$observeStores$1 = new PremiumGuildViewModel$sam$rx_functions_Func5$0(premiumGuildViewModel$Companion$observeStores$1);
|
|
}
|
|
Observable<StoreState> g = Observable.g(observePremiumGuildSubscriptionsState$default, observeSubscriptions, observeMe$default, observeGuild, observeState, (Func5) premiumGuildViewModel$Companion$observeStores$1);
|
|
m.checkNotNullExpressionValue(g, "Observable.combineLatest… ::StoreState\n )");
|
|
return g;
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static abstract class Event {
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class LaunchPurchaseSubscription extends Event {
|
|
private final long guildId;
|
|
private final String oldSkuName;
|
|
private final String section;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public LaunchPurchaseSubscription(String str, long j, String str2) {
|
|
super(null);
|
|
m.checkNotNullParameter(str, "section");
|
|
this.section = str;
|
|
this.guildId = j;
|
|
this.oldSkuName = str2;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ LaunchPurchaseSubscription(String str, long j, String str2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(str, j, (i & 4) != 0 ? null : str2);
|
|
}
|
|
|
|
public static /* synthetic */ LaunchPurchaseSubscription copy$default(LaunchPurchaseSubscription launchPurchaseSubscription, String str, long j, String str2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = launchPurchaseSubscription.section;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
j = launchPurchaseSubscription.guildId;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
str2 = launchPurchaseSubscription.oldSkuName;
|
|
}
|
|
return launchPurchaseSubscription.copy(str, j, str2);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.section;
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final String component3() {
|
|
return this.oldSkuName;
|
|
}
|
|
|
|
public final LaunchPurchaseSubscription copy(String str, long j, String str2) {
|
|
m.checkNotNullParameter(str, "section");
|
|
return new LaunchPurchaseSubscription(str, j, str2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof LaunchPurchaseSubscription)) {
|
|
return false;
|
|
}
|
|
LaunchPurchaseSubscription launchPurchaseSubscription = (LaunchPurchaseSubscription) obj;
|
|
return m.areEqual(this.section, launchPurchaseSubscription.section) && this.guildId == launchPurchaseSubscription.guildId && m.areEqual(this.oldSkuName, launchPurchaseSubscription.oldSkuName);
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final String getOldSkuName() {
|
|
return this.oldSkuName;
|
|
}
|
|
|
|
public final String getSection() {
|
|
return this.section;
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.section;
|
|
int i = 0;
|
|
int a = (b.a(this.guildId) + ((str != null ? str.hashCode() : 0) * 31)) * 31;
|
|
String str2 = this.oldSkuName;
|
|
if (str2 != null) {
|
|
i = str2.hashCode();
|
|
}
|
|
return a + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("LaunchPurchaseSubscription(section=");
|
|
K.append(this.section);
|
|
K.append(", guildId=");
|
|
K.append(this.guildId);
|
|
K.append(", oldSkuName=");
|
|
return a.C(K, this.oldSkuName, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class LaunchSubscriptionConfirmation extends Event {
|
|
private final long guildId;
|
|
private final long slotId;
|
|
|
|
public LaunchSubscriptionConfirmation(long j, long j2) {
|
|
super(null);
|
|
this.guildId = j;
|
|
this.slotId = j2;
|
|
}
|
|
|
|
public static /* synthetic */ LaunchSubscriptionConfirmation copy$default(LaunchSubscriptionConfirmation launchSubscriptionConfirmation, long j, long j2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = launchSubscriptionConfirmation.guildId;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
j2 = launchSubscriptionConfirmation.slotId;
|
|
}
|
|
return launchSubscriptionConfirmation.copy(j, j2);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.slotId;
|
|
}
|
|
|
|
public final LaunchSubscriptionConfirmation copy(long j, long j2) {
|
|
return new LaunchSubscriptionConfirmation(j, j2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof LaunchSubscriptionConfirmation)) {
|
|
return false;
|
|
}
|
|
LaunchSubscriptionConfirmation launchSubscriptionConfirmation = (LaunchSubscriptionConfirmation) obj;
|
|
return this.guildId == launchSubscriptionConfirmation.guildId && this.slotId == launchSubscriptionConfirmation.slotId;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final long getSlotId() {
|
|
return this.slotId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return b.a(this.slotId) + (b.a(this.guildId) * 31);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("LaunchSubscriptionConfirmation(guildId=");
|
|
K.append(this.guildId);
|
|
K.append(", slotId=");
|
|
return a.y(K, this.slotId, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class ShowBlockedPlanSwitchAlertDialog extends Event {
|
|
private final int bodyStringRes;
|
|
private final int headerStringRes;
|
|
|
|
public ShowBlockedPlanSwitchAlertDialog(@StringRes int i, @StringRes int i2) {
|
|
super(null);
|
|
this.headerStringRes = i;
|
|
this.bodyStringRes = i2;
|
|
}
|
|
|
|
public static /* synthetic */ ShowBlockedPlanSwitchAlertDialog copy$default(ShowBlockedPlanSwitchAlertDialog showBlockedPlanSwitchAlertDialog, int i, int i2, int i3, Object obj) {
|
|
if ((i3 & 1) != 0) {
|
|
i = showBlockedPlanSwitchAlertDialog.headerStringRes;
|
|
}
|
|
if ((i3 & 2) != 0) {
|
|
i2 = showBlockedPlanSwitchAlertDialog.bodyStringRes;
|
|
}
|
|
return showBlockedPlanSwitchAlertDialog.copy(i, i2);
|
|
}
|
|
|
|
public final int component1() {
|
|
return this.headerStringRes;
|
|
}
|
|
|
|
public final int component2() {
|
|
return this.bodyStringRes;
|
|
}
|
|
|
|
public final ShowBlockedPlanSwitchAlertDialog copy(@StringRes int i, @StringRes int i2) {
|
|
return new ShowBlockedPlanSwitchAlertDialog(i, i2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ShowBlockedPlanSwitchAlertDialog)) {
|
|
return false;
|
|
}
|
|
ShowBlockedPlanSwitchAlertDialog showBlockedPlanSwitchAlertDialog = (ShowBlockedPlanSwitchAlertDialog) obj;
|
|
return this.headerStringRes == showBlockedPlanSwitchAlertDialog.headerStringRes && this.bodyStringRes == showBlockedPlanSwitchAlertDialog.bodyStringRes;
|
|
}
|
|
|
|
public final int getBodyStringRes() {
|
|
return this.bodyStringRes;
|
|
}
|
|
|
|
public final int getHeaderStringRes() {
|
|
return this.headerStringRes;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return (this.headerStringRes * 31) + this.bodyStringRes;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ShowBlockedPlanSwitchAlertDialog(headerStringRes=");
|
|
K.append(this.headerStringRes);
|
|
K.append(", bodyStringRes=");
|
|
return a.w(K, this.bodyStringRes, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class ShowDesktopAlertDialog extends Event {
|
|
public static final ShowDesktopAlertDialog INSTANCE = new ShowDesktopAlertDialog();
|
|
|
|
private ShowDesktopAlertDialog() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class UnacknowledgedPurchase extends Event {
|
|
public static final UnacknowledgedPurchase INSTANCE = new UnacknowledgedPurchase();
|
|
|
|
private UnacknowledgedPurchase() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
private Event() {
|
|
}
|
|
|
|
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class StoreState {
|
|
private final Guild guild;
|
|
private final MeUser meUser;
|
|
private final StorePremiumGuildSubscription.State premiumGuildSubscriptionState;
|
|
private final StoreGooglePlayPurchases.State purchasesState;
|
|
private final StoreSubscriptions.SubscriptionsState subscriptionState;
|
|
|
|
public StoreState(StorePremiumGuildSubscription.State state, StoreSubscriptions.SubscriptionsState subscriptionsState, MeUser meUser, Guild guild, StoreGooglePlayPurchases.State state2) {
|
|
m.checkNotNullParameter(state, "premiumGuildSubscriptionState");
|
|
m.checkNotNullParameter(subscriptionsState, "subscriptionState");
|
|
m.checkNotNullParameter(meUser, "meUser");
|
|
m.checkNotNullParameter(state2, "purchasesState");
|
|
this.premiumGuildSubscriptionState = state;
|
|
this.subscriptionState = subscriptionsState;
|
|
this.meUser = meUser;
|
|
this.guild = guild;
|
|
this.purchasesState = state2;
|
|
}
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, StorePremiumGuildSubscription.State state, StoreSubscriptions.SubscriptionsState subscriptionsState, MeUser meUser, Guild guild, StoreGooglePlayPurchases.State state2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
state = storeState.premiumGuildSubscriptionState;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
subscriptionsState = storeState.subscriptionState;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
meUser = storeState.meUser;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
guild = storeState.guild;
|
|
}
|
|
if ((i & 16) != 0) {
|
|
state2 = storeState.purchasesState;
|
|
}
|
|
return storeState.copy(state, subscriptionsState, meUser, guild, state2);
|
|
}
|
|
|
|
public final StorePremiumGuildSubscription.State component1() {
|
|
return this.premiumGuildSubscriptionState;
|
|
}
|
|
|
|
public final StoreSubscriptions.SubscriptionsState component2() {
|
|
return this.subscriptionState;
|
|
}
|
|
|
|
public final MeUser component3() {
|
|
return this.meUser;
|
|
}
|
|
|
|
public final Guild component4() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final StoreGooglePlayPurchases.State component5() {
|
|
return this.purchasesState;
|
|
}
|
|
|
|
public final StoreState copy(StorePremiumGuildSubscription.State state, StoreSubscriptions.SubscriptionsState subscriptionsState, MeUser meUser, Guild guild, StoreGooglePlayPurchases.State state2) {
|
|
m.checkNotNullParameter(state, "premiumGuildSubscriptionState");
|
|
m.checkNotNullParameter(subscriptionsState, "subscriptionState");
|
|
m.checkNotNullParameter(meUser, "meUser");
|
|
m.checkNotNullParameter(state2, "purchasesState");
|
|
return new StoreState(state, subscriptionsState, meUser, guild, state2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StoreState)) {
|
|
return false;
|
|
}
|
|
StoreState storeState = (StoreState) obj;
|
|
return m.areEqual(this.premiumGuildSubscriptionState, storeState.premiumGuildSubscriptionState) && m.areEqual(this.subscriptionState, storeState.subscriptionState) && m.areEqual(this.meUser, storeState.meUser) && m.areEqual(this.guild, storeState.guild) && m.areEqual(this.purchasesState, storeState.purchasesState);
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final MeUser getMeUser() {
|
|
return this.meUser;
|
|
}
|
|
|
|
public final StorePremiumGuildSubscription.State getPremiumGuildSubscriptionState() {
|
|
return this.premiumGuildSubscriptionState;
|
|
}
|
|
|
|
public final StoreGooglePlayPurchases.State getPurchasesState() {
|
|
return this.purchasesState;
|
|
}
|
|
|
|
public final StoreSubscriptions.SubscriptionsState getSubscriptionState() {
|
|
return this.subscriptionState;
|
|
}
|
|
|
|
public int hashCode() {
|
|
StorePremiumGuildSubscription.State state = this.premiumGuildSubscriptionState;
|
|
int i = 0;
|
|
int hashCode = (state != null ? state.hashCode() : 0) * 31;
|
|
StoreSubscriptions.SubscriptionsState subscriptionsState = this.subscriptionState;
|
|
int hashCode2 = (hashCode + (subscriptionsState != null ? subscriptionsState.hashCode() : 0)) * 31;
|
|
MeUser meUser = this.meUser;
|
|
int hashCode3 = (hashCode2 + (meUser != null ? meUser.hashCode() : 0)) * 31;
|
|
Guild guild = this.guild;
|
|
int hashCode4 = (hashCode3 + (guild != null ? guild.hashCode() : 0)) * 31;
|
|
StoreGooglePlayPurchases.State state2 = this.purchasesState;
|
|
if (state2 != null) {
|
|
i = state2.hashCode();
|
|
}
|
|
return hashCode4 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("StoreState(premiumGuildSubscriptionState=");
|
|
K.append(this.premiumGuildSubscriptionState);
|
|
K.append(", subscriptionState=");
|
|
K.append(this.subscriptionState);
|
|
K.append(", meUser=");
|
|
K.append(this.meUser);
|
|
K.append(", guild=");
|
|
K.append(this.guild);
|
|
K.append(", purchasesState=");
|
|
K.append(this.purchasesState);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class Failure extends ViewState {
|
|
public static final Failure INSTANCE = new Failure();
|
|
|
|
private Failure() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.kt */
|
|
public static final class Loaded extends ViewState {
|
|
private final Guild guild;
|
|
private final MeUser meUser;
|
|
private final Map<Long, ModelPremiumGuildSubscriptionSlot> premiumGuildSubscriptionSlotMap;
|
|
private final List<Purchase> purchases;
|
|
private final List<ModelSubscription> subscriptions;
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: java.util.List<? extends com.android.billingclient.api.Purchase> */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Loaded(Map<Long, ModelPremiumGuildSubscriptionSlot> map, List<ModelSubscription> list, List<? extends Purchase> list2, MeUser meUser, Guild guild) {
|
|
super(null);
|
|
m.checkNotNullParameter(map, "premiumGuildSubscriptionSlotMap");
|
|
m.checkNotNullParameter(list, "subscriptions");
|
|
m.checkNotNullParameter(list2, "purchases");
|
|
m.checkNotNullParameter(meUser, "meUser");
|
|
m.checkNotNullParameter(guild, "guild");
|
|
this.premiumGuildSubscriptionSlotMap = map;
|
|
this.subscriptions = list;
|
|
this.purchases = list2;
|
|
this.meUser = meUser;
|
|
this.guild = guild;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: com.discord.widgets.servers.premiumguild.PremiumGuildViewModel$ViewState$Loaded */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, Map map, List list, List list2, MeUser meUser, Guild guild, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
map = loaded.premiumGuildSubscriptionSlotMap;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
list = loaded.subscriptions;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
list2 = loaded.purchases;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
meUser = loaded.meUser;
|
|
}
|
|
if ((i & 16) != 0) {
|
|
guild = loaded.guild;
|
|
}
|
|
return loaded.copy(map, list, list2, meUser, guild);
|
|
}
|
|
|
|
public final Map<Long, ModelPremiumGuildSubscriptionSlot> component1() {
|
|
return this.premiumGuildSubscriptionSlotMap;
|
|
}
|
|
|
|
public final List<ModelSubscription> component2() {
|
|
return this.subscriptions;
|
|
}
|
|
|
|
public final List<Purchase> component3() {
|
|
return this.purchases;
|
|
}
|
|
|
|
public final MeUser component4() {
|
|
return this.meUser;
|
|
}
|
|
|
|
public final Guild component5() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Loaded copy(Map<Long, ModelPremiumGuildSubscriptionSlot> map, List<ModelSubscription> list, List<? extends Purchase> list2, MeUser meUser, Guild guild) {
|
|
m.checkNotNullParameter(map, "premiumGuildSubscriptionSlotMap");
|
|
m.checkNotNullParameter(list, "subscriptions");
|
|
m.checkNotNullParameter(list2, "purchases");
|
|
m.checkNotNullParameter(meUser, "meUser");
|
|
m.checkNotNullParameter(guild, "guild");
|
|
return new Loaded(map, list, list2, meUser, guild);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Loaded)) {
|
|
return false;
|
|
}
|
|
Loaded loaded = (Loaded) obj;
|
|
return m.areEqual(this.premiumGuildSubscriptionSlotMap, loaded.premiumGuildSubscriptionSlotMap) && m.areEqual(this.subscriptions, loaded.subscriptions) && m.areEqual(this.purchases, loaded.purchases) && m.areEqual(this.meUser, loaded.meUser) && m.areEqual(this.guild, loaded.guild);
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final MeUser getMeUser() {
|
|
return this.meUser;
|
|
}
|
|
|
|
public final Map<Long, ModelPremiumGuildSubscriptionSlot> getPremiumGuildSubscriptionSlotMap() {
|
|
return this.premiumGuildSubscriptionSlotMap;
|
|
}
|
|
|
|
public final List<Purchase> getPurchases() {
|
|
return this.purchases;
|
|
}
|
|
|
|
public final List<ModelSubscription> getSubscriptions() {
|
|
return this.subscriptions;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Map<Long, ModelPremiumGuildSubscriptionSlot> map = this.premiumGuildSubscriptionSlotMap;
|
|
int i = 0;
|
|
int hashCode = (map != null ? map.hashCode() : 0) * 31;
|
|
List<ModelSubscription> list = this.subscriptions;
|
|
int hashCode2 = (hashCode + (list != null ? list.hashCode() : 0)) * 31;
|
|
List<Purchase> list2 = this.purchases;
|
|
int hashCode3 = (hashCode2 + (list2 != null ? list2.hashCode() : 0)) * 31;
|
|
MeUser meUser = this.meUser;
|
|
int hashCode4 = (hashCode3 + (meUser != null ? meUser.hashCode() : 0)) * 31;
|
|
Guild guild = this.guild;
|
|
if (guild != null) {
|
|
i = guild.hashCode();
|
|
}
|
|
return hashCode4 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("Loaded(premiumGuildSubscriptionSlotMap=");
|
|
K.append(this.premiumGuildSubscriptionSlotMap);
|
|
K.append(", subscriptions=");
|
|
K.append(this.subscriptions);
|
|
K.append(", purchases=");
|
|
K.append(this.purchases);
|
|
K.append(", meUser=");
|
|
K.append(this.meUser);
|
|
K.append(", guild=");
|
|
K.append(this.guild);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: PremiumGuildViewModel.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 PremiumGuildViewModel(long j, StorePremiumGuildSubscription storePremiumGuildSubscription, StoreSubscriptions storeSubscriptions, Clock clock, Observable<StoreState> observable) {
|
|
super(ViewState.Loading.INSTANCE);
|
|
m.checkNotNullParameter(storePremiumGuildSubscription, "storePremiumGuildSubscription");
|
|
m.checkNotNullParameter(storeSubscriptions, "storeSubscriptions");
|
|
m.checkNotNullParameter(clock, "clock");
|
|
m.checkNotNullParameter(observable, "storeObservable");
|
|
this.guildId = j;
|
|
this.storePremiumGuildSubscription = storePremiumGuildSubscription;
|
|
this.storeSubscriptions = storeSubscriptions;
|
|
this.clock = clock;
|
|
this.eventSubject = PublishSubject.k0();
|
|
fetchData();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), PremiumGuildViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ PremiumGuildViewModel(long j, StorePremiumGuildSubscription storePremiumGuildSubscription, StoreSubscriptions storeSubscriptions, Clock clock, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, (i & 2) != 0 ? StoreStream.Companion.getPremiumGuildSubscriptions() : storePremiumGuildSubscription, (i & 4) != 0 ? StoreStream.Companion.getSubscriptions() : storeSubscriptions, (i & 8) != 0 ? ClockFactory.get() : clock, (i & 16) != 0 ? Companion.access$observeStores(Companion, j) : observable);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(PremiumGuildViewModel premiumGuildViewModel, StoreState storeState) {
|
|
premiumGuildViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
private final void fetchData() {
|
|
this.storePremiumGuildSubscription.fetchUserGuildPremiumState();
|
|
this.storeSubscriptions.fetchSubscriptions();
|
|
GooglePlayBillingManager.INSTANCE.queryPurchases();
|
|
}
|
|
|
|
@MainThread
|
|
private final void handleStoreState(StoreState storeState) {
|
|
Object obj;
|
|
StorePremiumGuildSubscription.State premiumGuildSubscriptionState = storeState.getPremiumGuildSubscriptionState();
|
|
StoreSubscriptions.SubscriptionsState subscriptionState = storeState.getSubscriptionState();
|
|
StoreGooglePlayPurchases.State purchasesState = storeState.getPurchasesState();
|
|
if ((premiumGuildSubscriptionState instanceof StorePremiumGuildSubscription.State.Loading) || (subscriptionState instanceof StoreSubscriptions.SubscriptionsState.Loading) || (purchasesState instanceof StoreGooglePlayPurchases.State.Uninitialized)) {
|
|
obj = ViewState.Loading.INSTANCE;
|
|
} else if ((premiumGuildSubscriptionState instanceof StorePremiumGuildSubscription.State.Failure) || (subscriptionState instanceof StoreSubscriptions.SubscriptionsState.Failure)) {
|
|
obj = ViewState.Failure.INSTANCE;
|
|
} else if (!(premiumGuildSubscriptionState instanceof StorePremiumGuildSubscription.State.Loaded) || !(subscriptionState instanceof StoreSubscriptions.SubscriptionsState.Loaded) || !(purchasesState instanceof StoreGooglePlayPurchases.State.Loaded)) {
|
|
obj = ViewState.Failure.INSTANCE;
|
|
} else if (storeState.getGuild() == null) {
|
|
ViewState.Failure failure = ViewState.Failure.INSTANCE;
|
|
return;
|
|
} else {
|
|
obj = new ViewState.Loaded(((StorePremiumGuildSubscription.State.Loaded) premiumGuildSubscriptionState).getPremiumGuildSubscriptionSlotMap(), ((StoreSubscriptions.SubscriptionsState.Loaded) subscriptionState).getSubscriptions(), ((StoreGooglePlayPurchases.State.Loaded) purchasesState).getPurchases(), storeState.getMeUser(), storeState.getGuild());
|
|
}
|
|
updateViewState(obj);
|
|
}
|
|
|
|
public final Observable<Event> observeEvents() {
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
|
|
return publishSubject;
|
|
}
|
|
|
|
@MainThread
|
|
public final void retryClicked() {
|
|
fetchData();
|
|
}
|
|
|
|
@MainThread
|
|
public final void subscribeClicked(String str) {
|
|
boolean z2;
|
|
m.checkNotNullParameter(str, "section");
|
|
ViewState viewState = getViewState();
|
|
String str2 = null;
|
|
if (!(viewState instanceof ViewState.Loaded)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
|
|
if (loaded != null) {
|
|
Map<Long, ModelPremiumGuildSubscriptionSlot> premiumGuildSubscriptionSlotMap = loaded.getPremiumGuildSubscriptionSlotMap();
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
Iterator<Map.Entry<Long, ModelPremiumGuildSubscriptionSlot>> it = premiumGuildSubscriptionSlotMap.entrySet().iterator();
|
|
while (true) {
|
|
z2 = false;
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
Map.Entry<Long, ModelPremiumGuildSubscriptionSlot> next = it.next();
|
|
ModelPremiumGuildSubscriptionSlot value = next.getValue();
|
|
if (value.getCooldownExpiresAtTimestamp() < this.clock.currentTimeMillis()) {
|
|
ModelPremiumGuildSubscription premiumGuildSubscription = value.getPremiumGuildSubscription();
|
|
if ((premiumGuildSubscription != null ? Long.valueOf(premiumGuildSubscription.getGuildId()) : null) == null) {
|
|
z2 = true;
|
|
}
|
|
}
|
|
if (z2) {
|
|
linkedHashMap.put(next.getKey(), next.getValue());
|
|
}
|
|
}
|
|
if (!linkedHashMap.isEmpty()) {
|
|
this.eventSubject.j.onNext(new Event.LaunchSubscriptionConfirmation(loaded.getGuild().getId(), ((ModelPremiumGuildSubscriptionSlot) u.first(linkedHashMap.values())).getId()));
|
|
return;
|
|
}
|
|
ModelSubscription modelSubscription = (ModelSubscription) u.firstOrNull((List<? extends Object>) loaded.getSubscriptions());
|
|
if (modelSubscription == null || modelSubscription.isGoogleSubscription()) {
|
|
if ((modelSubscription != null ? modelSubscription.getRenewalMutations() : null) != null) {
|
|
this.eventSubject.j.onNext(new Event.ShowBlockedPlanSwitchAlertDialog(2131892286, 2131892284));
|
|
return;
|
|
}
|
|
if ((modelSubscription != null ? modelSubscription.getStatus() : null) == ModelSubscription.Status.CANCELED) {
|
|
this.eventSubject.j.onNext(new Event.ShowBlockedPlanSwitchAlertDialog(2131892286, 2131892283));
|
|
return;
|
|
}
|
|
if ((modelSubscription != null ? modelSubscription.getStatus() : null) == ModelSubscription.Status.ACCOUNT_HOLD) {
|
|
this.eventSubject.j.onNext(new Event.ShowBlockedPlanSwitchAlertDialog(2131892282, 2131892281));
|
|
return;
|
|
}
|
|
List<Purchase> purchases = loaded.getPurchases();
|
|
if (!(purchases instanceof Collection) || !purchases.isEmpty()) {
|
|
Iterator<T> it2 = purchases.iterator();
|
|
while (true) {
|
|
if (it2.hasNext()) {
|
|
if (!((Purchase) it2.next()).c()) {
|
|
z2 = true;
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (z2) {
|
|
this.eventSubject.j.onNext(Event.UnacknowledgedPurchase.INSTANCE);
|
|
return;
|
|
}
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
long id2 = loaded.getGuild().getId();
|
|
ModelSubscription modelSubscription2 = (ModelSubscription) u.firstOrNull((List<? extends Object>) loaded.getSubscriptions());
|
|
if (modelSubscription2 != null) {
|
|
str2 = modelSubscription2.getPaymentGatewayPlanId();
|
|
}
|
|
publishSubject.j.onNext(new Event.LaunchPurchaseSubscription(str, id2, str2));
|
|
return;
|
|
}
|
|
this.eventSubject.j.onNext(Event.ShowDesktopAlertDialog.INSTANCE);
|
|
}
|
|
}
|
|
}
|