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

90 lines
3.3 KiB
Java

package com.discord.stores;
import c0.t.r;
import c0.z.d.m;
import com.discord.app.AppLog;
import com.discord.stores.updates.ObservationDeck;
import com.discord.utilities.logging.Logger;
import java.util.HashSet;
import java.util.Set;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
/* compiled from: StoreV2.kt */
public abstract class StoreV2 extends Store implements DispatchHandler, ObservationDeck.UpdateSource {
private final Set<ObservationDeck.UpdateSource> updateSources = new HashSet();
/* compiled from: StoreV2.kt */
public static final class MarkChangedDelegate<T> {
private final ObservationDeck.UpdateSource overrideUpdateSource;
private T value;
public MarkChangedDelegate(T t, ObservationDeck.UpdateSource updateSource) {
this.value = t;
this.overrideUpdateSource = updateSource;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ MarkChangedDelegate(Object obj, ObservationDeck.UpdateSource updateSource, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(obj, (i & 2) != 0 ? null : updateSource);
}
public final T getValue(StoreV2 storeV2, KProperty<?> kProperty) {
m.checkNotNullParameter(kProperty, "property");
return this.value;
}
public final void setValue(StoreV2 storeV2, KProperty<?> kProperty, T t) {
m.checkNotNullParameter(kProperty, "property");
if (!m.areEqual(this.value, t)) {
this.value = t;
ObservationDeck.UpdateSource updateSource = this.overrideUpdateSource;
if (updateSource != null) {
if (storeV2 != null) {
storeV2.markChanged(updateSource);
}
} else if (storeV2 != null) {
storeV2.markChanged();
}
}
}
}
private final void assertStoreThread() {
Thread currentThread = Thread.currentThread();
m.checkNotNullExpressionValue(currentThread, "Thread.currentThread()");
if (currentThread.getId() != StoreStream.Companion.getSTORE_THREAD_ID()) {
Logger.e$default(AppLog.g, "markChanged() should be run from the Store Dispatcher", new IllegalStateException("Dispatch not run on store thread"), null, 4, null);
}
}
public final Set<ObservationDeck.UpdateSource> getUpdateSources() {
return this.updateSources;
}
public final void markChanged() {
assertStoreThread();
this.updateSources.add(this);
}
public final void markChanged(ObservationDeck.UpdateSource... updateSourceArr) {
m.checkNotNullParameter(updateSourceArr, "updates");
assertStoreThread();
markChanged();
r.addAll(this.updateSources, updateSourceArr);
}
public final void markUnchanged(ObservationDeck.UpdateSource updateSource) {
m.checkNotNullParameter(updateSource, "updateSource");
assertStoreThread();
this.updateSources.remove(updateSource);
}
@Override // com.discord.stores.DispatchHandler
public void onDispatchEnded() {
this.updateSources.clear();
}
public void snapshotData() {
}
}