2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.stores;
|
|
|
|
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.discord.api.channel.Channel;
|
|
|
|
import com.discord.api.thread.ThreadListing;
|
|
|
|
import com.discord.api.thread.ThreadMetadata;
|
|
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
|
|
import com.discord.utilities.rest.RestAPI;
|
|
|
|
import d0.t.u;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import kotlin.Pair;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import rx.Observable;
|
|
|
|
import rx.Subscription;
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public final class ArchivedThreadsStore extends StoreV2 {
|
|
|
|
private final Dispatcher dispatcher;
|
|
|
|
private Map<Pair<Long, ThreadListingType>, Subscription> fetchSubscriptions;
|
|
|
|
private Map<Pair<Long, ThreadListingType>, ThreadListingState> listings;
|
|
|
|
private Map<Pair<Long, ThreadListingType>, ? extends ThreadListingState> listingsSnapshot;
|
|
|
|
private final ObservationDeck observationDeck;
|
|
|
|
private final StoreStream storeStream;
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public static abstract class ThreadListingState {
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public static final class Error extends ThreadListingState {
|
|
|
|
public static final Error INSTANCE = new Error();
|
|
|
|
|
|
|
|
private Error() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public static final class Listing extends ThreadListingState {
|
|
|
|
private final boolean hasMore;
|
|
|
|
private final boolean isLoadingMore;
|
|
|
|
private final List<Channel> threads;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public Listing(List<Channel> list, boolean z2, boolean z3) {
|
|
|
|
super(null);
|
|
|
|
m.checkNotNullParameter(list, "threads");
|
|
|
|
this.threads = list;
|
|
|
|
this.hasMore = z2;
|
|
|
|
this.isLoadingMore = z3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.stores.ArchivedThreadsStore$ThreadListingState$Listing */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public static /* synthetic */ Listing copy$default(Listing listing, List list, boolean z2, boolean z3, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
list = listing.threads;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
z2 = listing.hasMore;
|
|
|
|
}
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
z3 = listing.isLoadingMore;
|
|
|
|
}
|
|
|
|
return listing.copy(list, z2, z3);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<Channel> component1() {
|
|
|
|
return this.threads;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component2() {
|
|
|
|
return this.hasMore;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component3() {
|
|
|
|
return this.isLoadingMore;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Listing copy(List<Channel> list, boolean z2, boolean z3) {
|
|
|
|
m.checkNotNullParameter(list, "threads");
|
|
|
|
return new Listing(list, z2, z3);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof Listing)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Listing listing = (Listing) obj;
|
|
|
|
return m.areEqual(this.threads, listing.threads) && this.hasMore == listing.hasMore && this.isLoadingMore == listing.isLoadingMore;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean getHasMore() {
|
|
|
|
return this.hasMore;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<Channel> getThreads() {
|
|
|
|
return this.threads;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
List<Channel> list = this.threads;
|
|
|
|
int hashCode = (list != null ? list.hashCode() : 0) * 31;
|
|
|
|
boolean z2 = this.hasMore;
|
|
|
|
int i = 1;
|
|
|
|
if (z2) {
|
|
|
|
z2 = true;
|
|
|
|
}
|
|
|
|
int i2 = z2 ? 1 : 0;
|
|
|
|
int i3 = z2 ? 1 : 0;
|
|
|
|
int i4 = z2 ? 1 : 0;
|
|
|
|
int i5 = (hashCode + i2) * 31;
|
|
|
|
boolean z3 = this.isLoadingMore;
|
|
|
|
if (!z3) {
|
|
|
|
i = z3 ? 1 : 0;
|
|
|
|
}
|
|
|
|
return i5 + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isLoadingMore() {
|
|
|
|
return this.isLoadingMore;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder L = a.L("Listing(threads=");
|
|
|
|
L.append(this.threads);
|
|
|
|
L.append(", hasMore=");
|
|
|
|
L.append(this.hasMore);
|
|
|
|
L.append(", isLoadingMore=");
|
|
|
|
return a.G(L, this.isLoadingMore, ")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public static final class Uninitialized extends ThreadListingState {
|
|
|
|
public static final Uninitialized INSTANCE = new Uninitialized();
|
|
|
|
|
|
|
|
private Uninitialized() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private ThreadListingState() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ ThreadListingState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
/* JADX INFO: Failed to restore enum class, 'enum' modifier removed */
|
|
|
|
public static final class ThreadListingType extends Enum<ThreadListingType> {
|
|
|
|
private static final /* synthetic */ ThreadListingType[] $VALUES;
|
|
|
|
public static final ThreadListingType ALL_ARCHIVED_PRIVATE_THREADS;
|
|
|
|
public static final ThreadListingType ALL_ARCHIVED_PUBLIC_THREADS;
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
public static final ThreadListingType MY_ARCHIVED_PRIVATE_THREADS;
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public static final class ALL_ARCHIVED_PRIVATE_THREADS extends ThreadListingType {
|
|
|
|
public ALL_ARCHIVED_PRIVATE_THREADS(String str, int i) {
|
|
|
|
super(str, i, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.stores.ArchivedThreadsStore.ThreadListingType
|
|
|
|
public Observable<ThreadListing> fetchNext(long j, List<Channel> list) {
|
|
|
|
m.checkNotNullParameter(list, "threads");
|
|
|
|
try {
|
|
|
|
return RestAPI.Companion.getApi().getAllPrivateArchivedThreads(j, Companion.access$getLastArchiveTimestamp(ThreadListingType.Companion, list));
|
|
|
|
} catch (IllegalStateException e) {
|
2021-07-03 23:36:06 +00:00
|
|
|
Observable<ThreadListing> w = Observable.w(e);
|
|
|
|
m.checkNotNullExpressionValue(w, "Observable.error(e)");
|
|
|
|
return w;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public static final class ALL_ARCHIVED_PUBLIC_THREADS extends ThreadListingType {
|
|
|
|
public ALL_ARCHIVED_PUBLIC_THREADS(String str, int i) {
|
|
|
|
super(str, i, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.stores.ArchivedThreadsStore.ThreadListingType
|
|
|
|
public Observable<ThreadListing> fetchNext(long j, List<Channel> list) {
|
|
|
|
m.checkNotNullParameter(list, "threads");
|
|
|
|
try {
|
|
|
|
return RestAPI.Companion.getApi().getAllPublicArchivedThreads(j, Companion.access$getLastArchiveTimestamp(ThreadListingType.Companion, list));
|
|
|
|
} catch (IllegalStateException e) {
|
2021-07-03 23:36:06 +00:00
|
|
|
Observable<ThreadListing> w = Observable.w(e);
|
|
|
|
m.checkNotNullExpressionValue(w, "Observable.error(e)");
|
|
|
|
return w;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ String access$getLastArchiveTimestamp(Companion companion, List list) {
|
|
|
|
return companion.getLastArchiveTimestamp(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final String getLastArchiveTimestamp(List<Channel> list) {
|
|
|
|
String a;
|
|
|
|
if (list.isEmpty()) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-07-03 23:36:06 +00:00
|
|
|
ThreadMetadata y2 = ((Channel) u.last((List<? extends Object>) list)).y();
|
|
|
|
if (y2 != null && (a = y2.a()) != null) {
|
2021-06-27 20:44:35 +00:00
|
|
|
return a;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("Thread missing threadMetadata");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: ArchivedThreadsStore.kt */
|
|
|
|
public static final class MY_ARCHIVED_PRIVATE_THREADS extends ThreadListingType {
|
|
|
|
public MY_ARCHIVED_PRIVATE_THREADS(String str, int i) {
|
|
|
|
super(str, i, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.stores.ArchivedThreadsStore.ThreadListingType
|
|
|
|
public Observable<ThreadListing> fetchNext(long j, List<Channel> list) {
|
|
|
|
m.checkNotNullParameter(list, "threads");
|
|
|
|
Channel channel = (Channel) u.lastOrNull((List<? extends Object>) list);
|
2021-07-03 23:36:06 +00:00
|
|
|
return RestAPI.Companion.getApi().getMyPrivateArchivedThreads(j, channel != null ? Long.valueOf(channel.h()) : null);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
|
|
|
MY_ARCHIVED_PRIVATE_THREADS my_archived_private_threads = new MY_ARCHIVED_PRIVATE_THREADS("MY_ARCHIVED_PRIVATE_THREADS", 0);
|
|
|
|
MY_ARCHIVED_PRIVATE_THREADS = my_archived_private_threads;
|
|
|
|
ALL_ARCHIVED_PUBLIC_THREADS all_archived_public_threads = new ALL_ARCHIVED_PUBLIC_THREADS("ALL_ARCHIVED_PUBLIC_THREADS", 1);
|
|
|
|
ALL_ARCHIVED_PUBLIC_THREADS = all_archived_public_threads;
|
|
|
|
ALL_ARCHIVED_PRIVATE_THREADS all_archived_private_threads = new ALL_ARCHIVED_PRIVATE_THREADS("ALL_ARCHIVED_PRIVATE_THREADS", 2);
|
|
|
|
ALL_ARCHIVED_PRIVATE_THREADS = all_archived_private_threads;
|
|
|
|
$VALUES = new ThreadListingType[]{my_archived_private_threads, all_archived_public_threads, all_archived_private_threads};
|
|
|
|
}
|
|
|
|
|
|
|
|
private ThreadListingType(String str, int i) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ ThreadListingType(String str, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this(str, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ThreadListingType valueOf(String str) {
|
|
|
|
return (ThreadListingType) Enum.valueOf(ThreadListingType.class, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ThreadListingType[] values() {
|
|
|
|
return (ThreadListingType[]) $VALUES.clone();
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract Observable<ThreadListing> fetchNext(long j, List<Channel> list);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArchivedThreadsStore(StoreStream storeStream, Dispatcher dispatcher, ObservationDeck observationDeck) {
|
|
|
|
m.checkNotNullParameter(storeStream, "storeStream");
|
|
|
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
|
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
|
|
this.storeStream = storeStream;
|
|
|
|
this.dispatcher = dispatcher;
|
|
|
|
this.observationDeck = observationDeck;
|
|
|
|
this.listings = new HashMap();
|
|
|
|
this.listingsSnapshot = new HashMap();
|
|
|
|
this.fetchSubscriptions = new HashMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
|
|
public /* synthetic */ ArchivedThreadsStore(StoreStream storeStream, Dispatcher dispatcher, ObservationDeck observationDeck, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this(storeStream, dispatcher, (i & 4) != 0 ? ObservationDeckProvider.get() : observationDeck);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Dispatcher access$getDispatcher$p(ArchivedThreadsStore archivedThreadsStore) {
|
|
|
|
return archivedThreadsStore.dispatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Map access$getFetchSubscriptions$p(ArchivedThreadsStore archivedThreadsStore) {
|
|
|
|
return archivedThreadsStore.fetchSubscriptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Map access$getListings$p(ArchivedThreadsStore archivedThreadsStore) {
|
|
|
|
return archivedThreadsStore.listings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Map access$getListingsSnapshot$p(ArchivedThreadsStore archivedThreadsStore) {
|
|
|
|
return archivedThreadsStore.listingsSnapshot;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ StoreStream access$getStoreStream$p(ArchivedThreadsStore archivedThreadsStore) {
|
|
|
|
return archivedThreadsStore.storeStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setFetchSubscriptions$p(ArchivedThreadsStore archivedThreadsStore, Map map) {
|
|
|
|
archivedThreadsStore.fetchSubscriptions = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setListings$p(ArchivedThreadsStore archivedThreadsStore, Map map) {
|
|
|
|
archivedThreadsStore.listings = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setListingsSnapshot$p(ArchivedThreadsStore archivedThreadsStore, Map map) {
|
|
|
|
archivedThreadsStore.listingsSnapshot = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ void fetchListing$default(ArchivedThreadsStore archivedThreadsStore, long j, ThreadListingType threadListingType, boolean z2, int i, Object obj) {
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
z2 = false;
|
|
|
|
}
|
|
|
|
archivedThreadsStore.fetchListing(j, threadListingType, z2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void fetchListing(long j, ThreadListingType threadListingType, boolean z2) {
|
|
|
|
m.checkNotNullParameter(threadListingType, "threadListingType");
|
|
|
|
this.dispatcher.schedule(new ArchivedThreadsStore$fetchListing$1(this, j, threadListingType, z2));
|
|
|
|
}
|
|
|
|
|
|
|
|
@StoreThread
|
|
|
|
public final void handleConnectionOpen() {
|
|
|
|
this.listings = new HashMap();
|
|
|
|
for (Subscription subscription : this.fetchSubscriptions.values()) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
this.fetchSubscriptions = new HashMap();
|
|
|
|
markChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Observable<ThreadListingState> loadAndObserveThreadListing(long j, ThreadListingType threadListingType) {
|
|
|
|
m.checkNotNullParameter(threadListingType, "threadListingType");
|
|
|
|
fetchListing(j, threadListingType, true);
|
2021-07-03 23:36:06 +00:00
|
|
|
Observable<ThreadListingState> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new ArchivedThreadsStore$loadAndObserveThreadListing$1(this, j, threadListingType), 14, null).r();
|
|
|
|
m.checkNotNullExpressionValue(r, "observationDeck.connectR… }.distinctUntilChanged()");
|
|
|
|
return r;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
|
|
@StoreThread
|
|
|
|
public void snapshotData() {
|
|
|
|
this.listingsSnapshot = new HashMap(this.listings);
|
|
|
|
}
|
|
|
|
}
|