package com.discord.stores; import c.d.b.a.a; import com.discord.models.domain.ModelChannelFollowerStats; import com.discord.stores.updates.ObservationDeck; import com.discord.utilities.time.ClockFactory; import d0.z.d.m; import java.util.HashMap; import java.util.Map; import kotlin.jvm.internal.DefaultConstructorMarker; import rx.Observable; /* compiled from: StoreChannelFollowerStats.kt */ public final class StoreChannelFollowerStats extends StoreV2 { public static final Companion Companion = new Companion(null); private static final int STALE_TIME_DIFF_MS = 3600000; private final Map channelFollowerStatsState = new HashMap(); private Map channelFollowerStatsStateSnapshot = new HashMap(); private final Dispatcher dispatcher; private final ObservationDeck observationDeck; /* compiled from: StoreChannelFollowerStats.kt */ public static final class ChannelFollowerStatData { private final ModelChannelFollowerStats data; private final FetchState fetchState; public ChannelFollowerStatData(FetchState fetchState, ModelChannelFollowerStats modelChannelFollowerStats) { m.checkNotNullParameter(fetchState, "fetchState"); m.checkNotNullParameter(modelChannelFollowerStats, "data"); this.fetchState = fetchState; this.data = modelChannelFollowerStats; } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ ChannelFollowerStatData(FetchState fetchState, ModelChannelFollowerStats modelChannelFollowerStats, int i, DefaultConstructorMarker defaultConstructorMarker) { this(fetchState, (i & 2) != 0 ? new ModelChannelFollowerStats(0, null, null, null, null, null, null, 127, null) : modelChannelFollowerStats); } public static /* synthetic */ ChannelFollowerStatData copy$default(ChannelFollowerStatData channelFollowerStatData, FetchState fetchState, ModelChannelFollowerStats modelChannelFollowerStats, int i, Object obj) { if ((i & 1) != 0) { fetchState = channelFollowerStatData.fetchState; } if ((i & 2) != 0) { modelChannelFollowerStats = channelFollowerStatData.data; } return channelFollowerStatData.copy(fetchState, modelChannelFollowerStats); } public final FetchState component1() { return this.fetchState; } public final ModelChannelFollowerStats component2() { return this.data; } public final ChannelFollowerStatData copy(FetchState fetchState, ModelChannelFollowerStats modelChannelFollowerStats) { m.checkNotNullParameter(fetchState, "fetchState"); m.checkNotNullParameter(modelChannelFollowerStats, "data"); return new ChannelFollowerStatData(fetchState, modelChannelFollowerStats); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof ChannelFollowerStatData)) { return false; } ChannelFollowerStatData channelFollowerStatData = (ChannelFollowerStatData) obj; return m.areEqual(this.fetchState, channelFollowerStatData.fetchState) && m.areEqual(this.data, channelFollowerStatData.data); } public final ModelChannelFollowerStats getData() { return this.data; } public final FetchState getFetchState() { return this.fetchState; } public int hashCode() { FetchState fetchState = this.fetchState; int i = 0; int hashCode = (fetchState != null ? fetchState.hashCode() : 0) * 31; ModelChannelFollowerStats modelChannelFollowerStats = this.data; if (modelChannelFollowerStats != null) { i = modelChannelFollowerStats.hashCode(); } return hashCode + i; } public String toString() { StringBuilder K = a.K("ChannelFollowerStatData(fetchState="); K.append(this.fetchState); K.append(", data="); K.append(this.data); K.append(")"); return K.toString(); } } /* compiled from: StoreChannelFollowerStats.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } } /* compiled from: StoreChannelFollowerStats.kt */ public enum FetchState { FETCHING, FAILED, SUCCEEDED } public StoreChannelFollowerStats(Dispatcher dispatcher, ObservationDeck observationDeck) { m.checkNotNullParameter(dispatcher, "dispatcher"); m.checkNotNullParameter(observationDeck, "observationDeck"); this.dispatcher = dispatcher; this.observationDeck = observationDeck; } public static final /* synthetic */ Map access$getChannelFollowerStatsState$p(StoreChannelFollowerStats storeChannelFollowerStats) { return storeChannelFollowerStats.channelFollowerStatsState; } public static final /* synthetic */ Map access$getChannelFollowerStatsStateSnapshot$p(StoreChannelFollowerStats storeChannelFollowerStats) { return storeChannelFollowerStats.channelFollowerStatsStateSnapshot; } public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreChannelFollowerStats storeChannelFollowerStats) { return storeChannelFollowerStats.dispatcher; } public static final /* synthetic */ void access$handleChannelFollowerStatsFetchFailed(StoreChannelFollowerStats storeChannelFollowerStats, long j) { storeChannelFollowerStats.handleChannelFollowerStatsFetchFailed(j); } public static final /* synthetic */ void access$handleChannelFollowerStatsFetchStart(StoreChannelFollowerStats storeChannelFollowerStats, long j) { storeChannelFollowerStats.handleChannelFollowerStatsFetchStart(j); } public static final /* synthetic */ void access$handleChannelFollowerStatsFetchSuccess(StoreChannelFollowerStats storeChannelFollowerStats, long j, ModelChannelFollowerStats modelChannelFollowerStats) { storeChannelFollowerStats.handleChannelFollowerStatsFetchSuccess(j, modelChannelFollowerStats); } public static final /* synthetic */ boolean access$isExisting(StoreChannelFollowerStats storeChannelFollowerStats, long j) { return storeChannelFollowerStats.isExisting(j); } public static final /* synthetic */ boolean access$isStale(StoreChannelFollowerStats storeChannelFollowerStats, long j) { return storeChannelFollowerStats.isStale(j); } public static final /* synthetic */ void access$setChannelFollowerStatsStateSnapshot$p(StoreChannelFollowerStats storeChannelFollowerStats, Map map) { storeChannelFollowerStats.channelFollowerStatsStateSnapshot = map; } @StoreThread private final void fetchIfNonexistingOrStale(long j) { this.dispatcher.schedule(new StoreChannelFollowerStats$fetchIfNonexistingOrStale$1(this, j)); } @StoreThread private final void handleChannelFollowerStatsFetchFailed(long j) { this.channelFollowerStatsState.put(Long.valueOf(j), new ChannelFollowerStatData(FetchState.FAILED, null, 2, null)); markChanged(); } @StoreThread private final void handleChannelFollowerStatsFetchStart(long j) { this.channelFollowerStatsState.put(Long.valueOf(j), new ChannelFollowerStatData(FetchState.FETCHING, null, 2, null)); markChanged(); } @StoreThread private final void handleChannelFollowerStatsFetchSuccess(long j, ModelChannelFollowerStats modelChannelFollowerStats) { this.channelFollowerStatsState.put(Long.valueOf(j), new ChannelFollowerStatData(FetchState.SUCCEEDED, modelChannelFollowerStats)); markChanged(); } @StoreThread private final boolean isExisting(long j) { ChannelFollowerStatData channelFollowerStatData = this.channelFollowerStatsState.get(Long.valueOf(j)); return (channelFollowerStatData == null || channelFollowerStatData.getFetchState() == FetchState.FAILED) ? false : true; } @StoreThread private final boolean isStale(long j) { ModelChannelFollowerStats data; ChannelFollowerStatData channelFollowerStatData = this.channelFollowerStatsState.get(Long.valueOf(j)); return ((channelFollowerStatData == null || (data = channelFollowerStatData.getData()) == null) ? 0 : data.getLastFetched() + ((long) 3600000)) <= ClockFactory.get().currentTimeMillis(); } public final void fetchChannelFollowerStats(long j) { fetchIfNonexistingOrStale(j); } public final Observable observeChannelFollowerStats(long j) { Observable r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannelFollowerStats$observeChannelFollowerStats$1(this, j), 14, null).r(); m.checkNotNullExpressionValue(r, "observationDeck\n … .distinctUntilChanged()"); return r; } @Override // com.discord.stores.StoreV2 @StoreThread public void snapshotData() { this.channelFollowerStatsStateSnapshot = new HashMap(this.channelFollowerStatsState); } }