96 lines
3.9 KiB
Java
96 lines
3.9 KiB
Java
package com.discord.stores;
|
|
|
|
import com.discord.models.domain.ModelUserProfile;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
import d0.t.h0;
|
|
import d0.z.d.m;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.Map;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: StoreUserProfile.kt */
|
|
public final class StoreUserProfile extends StoreV2 {
|
|
private final Dispatcher dispatcher;
|
|
private final ModelUserProfile emptyProfile;
|
|
private final ObservationDeck observationDeck;
|
|
private final HashMap<Long, ModelUserProfile> profiles;
|
|
private final HashSet<Long> profilesLoading;
|
|
private Map<Long, ? extends ModelUserProfile> profilesSnapshot;
|
|
|
|
public StoreUserProfile(Dispatcher dispatcher, ObservationDeck observationDeck) {
|
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
this.dispatcher = dispatcher;
|
|
this.observationDeck = observationDeck;
|
|
this.emptyProfile = new ModelUserProfile();
|
|
this.profilesLoading = new HashSet<>();
|
|
this.profiles = new HashMap<>();
|
|
this.profilesSnapshot = h0.emptyMap();
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ StoreUserProfile(Dispatcher dispatcher, ObservationDeck observationDeck, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(dispatcher, (i & 2) != 0 ? ObservationDeckProvider.get() : observationDeck);
|
|
}
|
|
|
|
public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreUserProfile storeUserProfile) {
|
|
return storeUserProfile.dispatcher;
|
|
}
|
|
|
|
public static final /* synthetic */ ModelUserProfile access$getEmptyProfile$p(StoreUserProfile storeUserProfile) {
|
|
return storeUserProfile.emptyProfile;
|
|
}
|
|
|
|
public static final /* synthetic */ HashSet access$getProfilesLoading$p(StoreUserProfile storeUserProfile) {
|
|
return storeUserProfile.profilesLoading;
|
|
}
|
|
|
|
public static final /* synthetic */ Map access$getProfilesSnapshot$p(StoreUserProfile storeUserProfile) {
|
|
return storeUserProfile.profilesSnapshot;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleFailure(StoreUserProfile storeUserProfile, long j) {
|
|
storeUserProfile.handleFailure(j);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleUserProfile(StoreUserProfile storeUserProfile, ModelUserProfile modelUserProfile, long j) {
|
|
storeUserProfile.handleUserProfile(modelUserProfile, j);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setProfilesSnapshot$p(StoreUserProfile storeUserProfile, Map map) {
|
|
storeUserProfile.profilesSnapshot = map;
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleFailure(long j) {
|
|
this.profilesLoading.remove(Long.valueOf(j));
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleUserProfile(ModelUserProfile modelUserProfile, long j) {
|
|
this.profilesLoading.remove(Long.valueOf(j));
|
|
this.profiles.put(Long.valueOf(j), modelUserProfile);
|
|
markChanged();
|
|
}
|
|
|
|
public final Observable<ModelUserProfile> observeUserProfile(long j) {
|
|
request(j);
|
|
Observable<ModelUserProfile> s2 = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreUserProfile$observeUserProfile$1(this, j), 14, null).s();
|
|
m.checkNotNullExpressionValue(s2, "observationDeck.connectR… }.distinctUntilChanged()");
|
|
return s2;
|
|
}
|
|
|
|
public final void request(long j) {
|
|
this.dispatcher.schedule(new StoreUserProfile$request$1(this, j));
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
@StoreThread
|
|
public void snapshotData() {
|
|
super.snapshotData();
|
|
this.profilesSnapshot = new HashMap(this.profiles);
|
|
}
|
|
}
|