discord-jadx/app/src/main/java/com/discord/stores/StorePaymentSources.java

239 lines
10 KiB
Java

package com.discord.stores;
import c.d.b.a.a;
import com.discord.models.domain.ModelPaymentSource;
import com.discord.models.domain.PaymentSourceRaw;
import com.discord.stores.updates.ObservationDeck;
import com.discord.stores.updates.ObservationDeckProvider;
import com.discord.utilities.rest.RestAPI;
import d0.t.n;
import d0.t.o;
import d0.t.u;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
/* compiled from: StorePaymentSources.kt */
public final class StorePaymentSources extends StoreV2 {
private final Dispatcher dispatcher;
private final ObservationDeck observationDeck;
private PaymentSourcesState paymentSourcesState;
private PaymentSourcesState paymentSourcesStateSnapshot;
private final RestAPI restAPI;
/* compiled from: StorePaymentSources.kt */
public static abstract class PaymentSourcesState {
/* compiled from: StorePaymentSources.kt */
public static final class Failure extends PaymentSourcesState {
public static final Failure INSTANCE = new Failure();
private Failure() {
super(null);
}
}
/* compiled from: StorePaymentSources.kt */
public static final class Loaded extends PaymentSourcesState {
private final List<ModelPaymentSource> paymentSources;
/* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: java.util.List<? extends com.discord.models.domain.ModelPaymentSource> */
/* JADX WARN: Multi-variable type inference failed */
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Loaded(List<? extends ModelPaymentSource> list) {
super(null);
m.checkNotNullParameter(list, "paymentSources");
this.paymentSources = list;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.stores.StorePaymentSources$PaymentSourcesState$Loaded */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Loaded copy$default(Loaded loaded, List list, int i, Object obj) {
if ((i & 1) != 0) {
list = loaded.paymentSources;
}
return loaded.copy(list);
}
public final List<ModelPaymentSource> component1() {
return this.paymentSources;
}
public final Loaded copy(List<? extends ModelPaymentSource> list) {
m.checkNotNullParameter(list, "paymentSources");
return new Loaded(list);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof Loaded) && m.areEqual(this.paymentSources, ((Loaded) obj).paymentSources);
}
return true;
}
public final List<ModelPaymentSource> getPaymentSources() {
return this.paymentSources;
}
public int hashCode() {
List<ModelPaymentSource> list = this.paymentSources;
if (list != null) {
return list.hashCode();
}
return 0;
}
public String toString() {
return a.D(a.K("Loaded(paymentSources="), this.paymentSources, ")");
}
}
/* compiled from: StorePaymentSources.kt */
public static final class Loading extends PaymentSourcesState {
public static final Loading INSTANCE = new Loading();
private Loading() {
super(null);
}
}
/* compiled from: StorePaymentSources.kt */
public static final class Unfetched extends PaymentSourcesState {
public static final Unfetched INSTANCE = new Unfetched();
private Unfetched() {
super(null);
}
}
private PaymentSourcesState() {
}
public /* synthetic */ PaymentSourcesState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public StorePaymentSources(Dispatcher dispatcher, ObservationDeck observationDeck, RestAPI restAPI) {
m.checkNotNullParameter(dispatcher, "dispatcher");
m.checkNotNullParameter(observationDeck, "observationDeck");
m.checkNotNullParameter(restAPI, "restAPI");
this.dispatcher = dispatcher;
this.observationDeck = observationDeck;
this.restAPI = restAPI;
PaymentSourcesState.Unfetched unfetched = PaymentSourcesState.Unfetched.INSTANCE;
this.paymentSourcesState = unfetched;
this.paymentSourcesStateSnapshot = unfetched;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ StorePaymentSources(Dispatcher dispatcher, ObservationDeck observationDeck, RestAPI restAPI, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(dispatcher, (i & 2) != 0 ? ObservationDeckProvider.get() : observationDeck, (i & 4) != 0 ? RestAPI.Companion.getApi() : restAPI);
}
public static final /* synthetic */ List access$ensureDefaultPaymentSource(StorePaymentSources storePaymentSources, List list) {
return storePaymentSources.ensureDefaultPaymentSource(list);
}
public static final /* synthetic */ Dispatcher access$getDispatcher$p(StorePaymentSources storePaymentSources) {
return storePaymentSources.dispatcher;
}
public static final /* synthetic */ PaymentSourcesState access$getPaymentSourcesState$p(StorePaymentSources storePaymentSources) {
return storePaymentSources.paymentSourcesState;
}
public static final /* synthetic */ RestAPI access$getRestAPI$p(StorePaymentSources storePaymentSources) {
return storePaymentSources.restAPI;
}
public static final /* synthetic */ void access$handlePaymentSourcesFetchFailure(StorePaymentSources storePaymentSources) {
storePaymentSources.handlePaymentSourcesFetchFailure();
}
public static final /* synthetic */ void access$handlePaymentSourcesFetchStart(StorePaymentSources storePaymentSources) {
storePaymentSources.handlePaymentSourcesFetchStart();
}
public static final /* synthetic */ void access$handlePaymentSourcesFetchSuccess(StorePaymentSources storePaymentSources, List list) {
storePaymentSources.handlePaymentSourcesFetchSuccess(list);
}
public static final /* synthetic */ void access$setPaymentSourcesState$p(StorePaymentSources storePaymentSources, PaymentSourcesState paymentSourcesState) {
storePaymentSources.paymentSourcesState = paymentSourcesState;
}
private final List<ModelPaymentSource> ensureDefaultPaymentSource(List<PaymentSourceRaw> list) {
if (list.isEmpty()) {
return n.emptyList();
}
List<PaymentSourceRaw> mutableList = u.toMutableList((Collection) u.sortedWith(list, new StorePaymentSources$ensureDefaultPaymentSource$$inlined$sortedBy$1()));
mutableList.set(0, PaymentSourceRaw.copy$default((PaymentSourceRaw) u.first((List<? extends Object>) mutableList), 0, null, false, null, true, null, null, null, 0, 0, 1007, null));
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(mutableList, 10));
for (PaymentSourceRaw paymentSourceRaw : mutableList) {
arrayList.add(ModelPaymentSource.Companion.wrap(paymentSourceRaw));
}
return arrayList;
}
@StoreThread
private final void handlePaymentSourcesFetchFailure() {
this.paymentSourcesState = PaymentSourcesState.Failure.INSTANCE;
markChanged();
}
@StoreThread
private final void handlePaymentSourcesFetchStart() {
this.paymentSourcesState = PaymentSourcesState.Loading.INSTANCE;
markChanged();
}
@StoreThread
private final void handlePaymentSourcesFetchSuccess(List<? extends ModelPaymentSource> list) {
this.paymentSourcesState = new PaymentSourcesState.Loaded(list);
markChanged();
}
public final void fetchPaymentSources() {
this.dispatcher.schedule(new StorePaymentSources$fetchPaymentSources$1(this));
}
public final PaymentSourcesState getPaymentSourcesState() {
return this.paymentSourcesStateSnapshot;
}
@StoreThread
public final void handlePreLogout() {
this.paymentSourcesState = PaymentSourcesState.Unfetched.INSTANCE;
markChanged();
}
@StoreThread
public final void handleUserPaymentSourcesUpdate() {
fetchPaymentSources();
}
public final Observable<PaymentSourcesState> observePaymentSourcesState() {
Observable<PaymentSourcesState> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StorePaymentSources$observePaymentSourcesState$1(this), 14, null).r();
m.checkNotNullExpressionValue(r, "observationDeck.connectR… }.distinctUntilChanged()");
return r;
}
@Override // com.discord.stores.StoreV2
@StoreThread
public void snapshotData() {
super.snapshotData();
PaymentSourcesState paymentSourcesState = this.paymentSourcesState;
if (paymentSourcesState instanceof PaymentSourcesState.Loaded) {
PaymentSourcesState.Loaded loaded = (PaymentSourcesState.Loaded) paymentSourcesState;
paymentSourcesState = loaded.copy(new ArrayList(loaded.getPaymentSources()));
} else if (!m.areEqual(paymentSourcesState, PaymentSourcesState.Loading.INSTANCE) && !m.areEqual(paymentSourcesState, PaymentSourcesState.Failure.INSTANCE) && !m.areEqual(paymentSourcesState, PaymentSourcesState.Unfetched.INSTANCE)) {
throw new NoWhenBranchMatchedException();
}
this.paymentSourcesStateSnapshot = paymentSourcesState;
}
}