122 lines
5.7 KiB
Java
122 lines
5.7 KiB
Java
package com.discord.stores;
|
|
|
|
import android.content.Context;
|
|
import com.discord.stores.StoreSearch;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.rx.ObservableWithLeadingEdgeThrottle;
|
|
import com.discord.utilities.search.validation.SearchData;
|
|
import d0.z.d.m;
|
|
import java.util.concurrent.TimeUnit;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import rx.Observable;
|
|
import rx.Subscription;
|
|
import rx.subjects.BehaviorSubject;
|
|
import rx.subjects.Subject;
|
|
/* compiled from: StoreSearchData.kt */
|
|
public final class StoreSearchData {
|
|
private final ObservationDeck observationDeck;
|
|
private final Subject<SearchData, SearchData> searchDataSubject;
|
|
private final StoreChannels storeChannels;
|
|
private final StoreGuilds storeGuilds;
|
|
private final StoreUser storeUser;
|
|
private Subscription subscription;
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
StoreSearch.SearchTarget.Type.values();
|
|
int[] iArr = new int[2];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[StoreSearch.SearchTarget.Type.GUILD.ordinal()] = 1;
|
|
iArr[StoreSearch.SearchTarget.Type.CHANNEL.ordinal()] = 2;
|
|
}
|
|
}
|
|
|
|
public StoreSearchData(ObservationDeck observationDeck, StoreChannels storeChannels, StoreUser storeUser, StoreGuilds storeGuilds) {
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
m.checkNotNullParameter(storeChannels, "storeChannels");
|
|
m.checkNotNullParameter(storeUser, "storeUser");
|
|
m.checkNotNullParameter(storeGuilds, "storeGuilds");
|
|
this.observationDeck = observationDeck;
|
|
this.storeChannels = storeChannels;
|
|
this.storeUser = storeUser;
|
|
this.storeGuilds = storeGuilds;
|
|
BehaviorSubject l0 = BehaviorSubject.l0(new SearchData(null, null, null, null, null, 31, null));
|
|
m.checkNotNullExpressionValue(l0, "BehaviorSubject.create(SearchData())");
|
|
this.searchDataSubject = l0;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreChannels access$getStoreChannels$p(StoreSearchData storeSearchData) {
|
|
return storeSearchData.storeChannels;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreGuilds access$getStoreGuilds$p(StoreSearchData storeSearchData) {
|
|
return storeSearchData.storeGuilds;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreUser access$getStoreUser$p(StoreSearchData storeSearchData) {
|
|
return storeSearchData.storeUser;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleNewData(StoreSearchData storeSearchData, SearchData searchData) {
|
|
storeSearchData.handleNewData(searchData);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleSubscription(StoreSearchData storeSearchData, Subscription subscription) {
|
|
storeSearchData.handleSubscription(subscription);
|
|
}
|
|
|
|
private final Observable<SearchData> getChannelSearchData(long j) {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this.storeChannels, this.storeUser, this.storeGuilds}, false, null, null, new StoreSearchData$getChannelSearchData$1(this, j), 14, null);
|
|
}
|
|
|
|
private final Observable<SearchData> getGuildSearchData(long j) {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable<SearchData> combineLatest = ObservableWithLeadingEdgeThrottle.combineLatest(companion.getGuilds().observeComputed(j), companion.getUsers().observeAllUsers(), StoreChannels.observeChannelsForGuild$default(companion.getChannels(), j, null, 2, null).F(StoreSearchData$getGuildSearchData$1.INSTANCE), companion.getPermissions().observeChannelPermissionsForGuild(j), new StoreSearchData$sam$rx_functions_Func4$0(new StoreSearchData$getGuildSearchData$2(new SearchData.Builder())), 3, TimeUnit.SECONDS);
|
|
m.checkNotNullExpressionValue(combineLatest, "ObservableWithLeadingEdg…3, TimeUnit.SECONDS\n )");
|
|
return combineLatest;
|
|
}
|
|
|
|
private final void handleNewData(SearchData searchData) {
|
|
this.searchDataSubject.onNext(searchData);
|
|
}
|
|
|
|
private final synchronized void handleSubscription(Subscription subscription) {
|
|
Subscription subscription2 = this.subscription;
|
|
if (subscription2 != null) {
|
|
subscription2.unsubscribe();
|
|
}
|
|
this.subscription = subscription;
|
|
}
|
|
|
|
public final void clear() {
|
|
handleSubscription(null);
|
|
handleNewData(new SearchData(null, null, null, null, null, 31, null));
|
|
}
|
|
|
|
public final Observable<SearchData> get() {
|
|
return this.searchDataSubject;
|
|
}
|
|
|
|
public final void init(StoreSearch.SearchTarget searchTarget) {
|
|
Observable<SearchData> observable;
|
|
m.checkNotNullParameter(searchTarget, "searchTarget");
|
|
int ordinal = searchTarget.getType().ordinal();
|
|
if (ordinal == 0) {
|
|
observable = getGuildSearchData(searchTarget.getId());
|
|
} else if (ordinal == 1) {
|
|
observable = getChannelSearchData(searchTarget.getId());
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
Observable r = ObservableExtensionsKt.computationBuffered(observable).r();
|
|
m.checkNotNullExpressionValue(r, "searchDataObservable\n … .distinctUntilChanged()");
|
|
ObservableExtensionsKt.appSubscribe$default(r, StoreSearchData.class, (Context) null, new StoreSearchData$init$1(this), (Function1) null, (Function0) null, (Function0) null, new StoreSearchData$init$2(this), 58, (Object) null);
|
|
}
|
|
}
|