79 lines
3 KiB
Java
79 lines
3 KiB
Java
package com.discord.stores;
|
|
|
|
import android.content.Context;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
import com.discord.utilities.persister.Persister;
|
|
import d0.t.n0;
|
|
import d0.z.d.m;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: StoreExpandedGuildFolders.kt */
|
|
public final class StoreExpandedGuildFolders extends StoreV2 {
|
|
private final Dispatcher dispatcher;
|
|
private final ObservationDeck observationDeck;
|
|
private final Set<Long> openFolderIds;
|
|
private final Persister<Set<Long>> openFolderIdsCache;
|
|
private Set<Long> openFolderIdsSnapshot;
|
|
|
|
public StoreExpandedGuildFolders(Dispatcher dispatcher, ObservationDeck observationDeck) {
|
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
this.dispatcher = dispatcher;
|
|
this.observationDeck = observationDeck;
|
|
this.openFolderIdsSnapshot = n0.emptySet();
|
|
this.openFolderIds = new HashSet();
|
|
this.openFolderIdsCache = new Persister<>("CACHE_KEY_OPEN_FOLDERS", new HashSet());
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ StoreExpandedGuildFolders(Dispatcher dispatcher, ObservationDeck observationDeck, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(dispatcher, (i & 2) != 0 ? ObservationDeckProvider.get() : observationDeck);
|
|
}
|
|
|
|
public final void closeFolder(long j) {
|
|
this.dispatcher.schedule(new StoreExpandedGuildFolders$closeFolder$1(this, j));
|
|
}
|
|
|
|
public final Set<Long> getOpenFolderIds() {
|
|
return this.openFolderIdsSnapshot;
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleFolderClosed(long j) {
|
|
this.openFolderIds.remove(Long.valueOf(j));
|
|
markChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleFolderOpened(long j) {
|
|
this.openFolderIds.add(Long.valueOf(j));
|
|
markChanged();
|
|
}
|
|
|
|
@Override // com.discord.stores.Store
|
|
public void init(Context context) {
|
|
m.checkNotNullParameter(context, "context");
|
|
this.openFolderIds.addAll(this.openFolderIdsCache.get());
|
|
markChanged();
|
|
}
|
|
|
|
public final Observable<Set<Long>> observeOpenFolderIds() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreExpandedGuildFolders$observeOpenFolderIds$1(this), 14, null);
|
|
}
|
|
|
|
public final void openFolder(long j) {
|
|
this.dispatcher.schedule(new StoreExpandedGuildFolders$openFolder$1(this, j));
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
@StoreThread
|
|
public void snapshotData() {
|
|
super.snapshotData();
|
|
HashSet hashSet = new HashSet(this.openFolderIds);
|
|
this.openFolderIdsSnapshot = hashSet;
|
|
Persister.set$default(this.openFolderIdsCache, hashSet, false, 2, null);
|
|
}
|
|
}
|