2021-08-09 22:50:52 +00:00
package com.discord.stores ;
2021-10-29 07:36:40 +00:00
import com.discord.app.AppLog ;
2021-08-09 22:50:52 +00:00
import com.discord.stores.updates.ObservationDeck ;
2021-10-29 07:36:40 +00:00
import com.discord.utilities.logging.Logger ;
2021-11-01 07:19:03 +00:00
import d0.t.r ;
import d0.z.d.m ;
2021-08-09 22:50:52 +00:00
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 ( ) ;
}
}
}
}
2021-10-29 07:36:40 +00:00
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 ) ;
}
}
2021-08-09 22:50:52 +00:00
public final Set < ObservationDeck . UpdateSource > getUpdateSources ( ) {
return this . updateSources ;
}
public final void markChanged ( ) {
2021-10-29 07:36:40 +00:00
assertStoreThread ( ) ;
2021-08-09 22:50:52 +00:00
this . updateSources . add ( this ) ;
}
public final void markChanged ( ObservationDeck . UpdateSource . . . updateSourceArr ) {
m . checkNotNullParameter ( updateSourceArr , " updates " ) ;
2021-10-29 07:36:40 +00:00
assertStoreThread ( ) ;
2021-08-09 22:50:52 +00:00
markChanged ( ) ;
r . addAll ( this . updateSources , updateSourceArr ) ;
}
public final void markUnchanged ( ObservationDeck . UpdateSource updateSource ) {
m . checkNotNullParameter ( updateSource , " updateSource " ) ;
2021-10-29 07:36:40 +00:00
assertStoreThread ( ) ;
2021-08-09 22:50:52 +00:00
this . updateSources . remove ( updateSource ) ;
}
@Override // com.discord.stores.DispatchHandler
public void onDispatchEnded ( ) {
this . updateSources . clear ( ) ;
}
public void snapshotData ( ) {
}
}