package com.discord.stores; import c.d.b.a.a; import com.discord.api.guild.welcome.GuildWelcomeScreen; import com.discord.stores.updates.ObservationDeck; import com.discord.stores.updates.ObservationDeckProvider; import d0.t.h0; import d0.t.n0; import d0.z.d.m; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import kotlin.jvm.internal.DefaultConstructorMarker; import rx.Observable; /* compiled from: StoreGuildWelcomeScreens.kt */ public final class StoreGuildWelcomeScreens extends StoreV2 { private final Dispatcher dispatcher; private final HashSet guildWelcomeScreensSeen; private Set guildWelcomeScreensSeenSnapshot; private Map guildWelcomeScreensSnapshot; private final HashMap guildWelcomeScreensState; private final ObservationDeck observationDeck; /* compiled from: StoreGuildWelcomeScreens.kt */ public static abstract class State { /* compiled from: StoreGuildWelcomeScreens.kt */ public static final class Failure extends State { public static final Failure INSTANCE = new Failure(); private Failure() { super(null); } } /* compiled from: StoreGuildWelcomeScreens.kt */ public static final class Fetching extends State { public static final Fetching INSTANCE = new Fetching(); private Fetching() { super(null); } } /* compiled from: StoreGuildWelcomeScreens.kt */ public static final class Loaded extends State { private final GuildWelcomeScreen data; public Loaded(GuildWelcomeScreen guildWelcomeScreen) { super(null); this.data = guildWelcomeScreen; } public static /* synthetic */ Loaded copy$default(Loaded loaded, GuildWelcomeScreen guildWelcomeScreen, int i, Object obj) { if ((i & 1) != 0) { guildWelcomeScreen = loaded.data; } return loaded.copy(guildWelcomeScreen); } public final GuildWelcomeScreen component1() { return this.data; } public final Loaded copy(GuildWelcomeScreen guildWelcomeScreen) { return new Loaded(guildWelcomeScreen); } public boolean equals(Object obj) { if (this != obj) { return (obj instanceof Loaded) && m.areEqual(this.data, ((Loaded) obj).data); } return true; } public final GuildWelcomeScreen getData() { return this.data; } public int hashCode() { GuildWelcomeScreen guildWelcomeScreen = this.data; if (guildWelcomeScreen != null) { return guildWelcomeScreen.hashCode(); } return 0; } public String toString() { StringBuilder L = a.L("Loaded(data="); L.append(this.data); L.append(")"); return L.toString(); } } private State() { } public /* synthetic */ State(DefaultConstructorMarker defaultConstructorMarker) { this(); } } public StoreGuildWelcomeScreens(Dispatcher dispatcher, ObservationDeck observationDeck) { m.checkNotNullParameter(dispatcher, "dispatcher"); m.checkNotNullParameter(observationDeck, "observationDeck"); this.dispatcher = dispatcher; this.observationDeck = observationDeck; this.guildWelcomeScreensSnapshot = h0.emptyMap(); this.guildWelcomeScreensSeenSnapshot = n0.emptySet(); this.guildWelcomeScreensState = new HashMap<>(); this.guildWelcomeScreensSeen = new HashSet<>(); } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ StoreGuildWelcomeScreens(Dispatcher dispatcher, ObservationDeck observationDeck, int i, DefaultConstructorMarker defaultConstructorMarker) { this(dispatcher, (i & 2) != 0 ? ObservationDeckProvider.get() : observationDeck); } public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreGuildWelcomeScreens storeGuildWelcomeScreens) { return storeGuildWelcomeScreens.dispatcher; } public static final /* synthetic */ HashSet access$getGuildWelcomeScreensSeen$p(StoreGuildWelcomeScreens storeGuildWelcomeScreens) { return storeGuildWelcomeScreens.guildWelcomeScreensSeen; } public static final /* synthetic */ HashMap access$getGuildWelcomeScreensState$p(StoreGuildWelcomeScreens storeGuildWelcomeScreens) { return storeGuildWelcomeScreens.guildWelcomeScreensState; } public static final /* synthetic */ void access$handleGuildWelcomeScreen(StoreGuildWelcomeScreens storeGuildWelcomeScreens, long j, GuildWelcomeScreen guildWelcomeScreen) { storeGuildWelcomeScreens.handleGuildWelcomeScreen(j, guildWelcomeScreen); } public static final /* synthetic */ void access$handleGuildWelcomeScreenFetchFailed(StoreGuildWelcomeScreens storeGuildWelcomeScreens, long j) { storeGuildWelcomeScreens.handleGuildWelcomeScreenFetchFailed(j); } public static final /* synthetic */ void access$handleGuildWelcomeScreenFetchStart(StoreGuildWelcomeScreens storeGuildWelcomeScreens, long j) { storeGuildWelcomeScreens.handleGuildWelcomeScreenFetchStart(j); } @StoreThread private final void handleGuildWelcomeScreen(long j, GuildWelcomeScreen guildWelcomeScreen) { this.guildWelcomeScreensState.put(Long.valueOf(j), new State.Loaded(guildWelcomeScreen)); markChanged(); } @StoreThread private final void handleGuildWelcomeScreenFetchFailed(long j) { this.guildWelcomeScreensState.put(Long.valueOf(j), State.Failure.INSTANCE); markChanged(); } @StoreThread private final void handleGuildWelcomeScreenFetchStart(long j) { this.guildWelcomeScreensState.put(Long.valueOf(j), State.Fetching.INSTANCE); markChanged(); } public final void fetchIfNonexisting(long j) { this.dispatcher.schedule(new StoreGuildWelcomeScreens$fetchIfNonexisting$1(this, j)); } public final State getGuildWelcomeScreen(long j) { return (State) this.guildWelcomeScreensSnapshot.get(Long.valueOf(j)); } public final void handleGuildJoined(long j, GuildWelcomeScreen guildWelcomeScreen) { handleGuildWelcomeScreen(j, guildWelcomeScreen); } public final boolean hasWelcomeScreenBeenSeen(long j) { return this.guildWelcomeScreensSeenSnapshot.contains(Long.valueOf(j)); } public final void markWelcomeScreenShown(long j) { this.dispatcher.schedule(new StoreGuildWelcomeScreens$markWelcomeScreenShown$1(this, j)); } public final Observable observeGuildWelcomeScreen(long j) { Observable r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreGuildWelcomeScreens$observeGuildWelcomeScreen$1(this, j), 14, null).r(); m.checkNotNullExpressionValue(r, "observationDeck.connectR… }.distinctUntilChanged()"); return r; } @Override // com.discord.stores.StoreV2 public void snapshotData() { super.snapshotData(); this.guildWelcomeScreensSnapshot = new HashMap(this.guildWelcomeScreensState); this.guildWelcomeScreensSeenSnapshot = new HashSet(this.guildWelcomeScreensSeen); } }