package com.discord.stores; import android.content.Context; import c.d.b.a.a; import com.discord.api.channel.Channel; import com.discord.api.channel.ChannelRecipient; import com.discord.api.channel.ChannelRecipientNick; import com.discord.api.channel.ChannelUtils; import com.discord.api.guild.Guild; import com.discord.api.user.User; import com.discord.models.domain.ModelPayload; import com.discord.models.message.Message; import com.discord.models.thread.dto.ModelThreadListSync; import com.discord.stores.updates.ObservationDeck; import com.discord.utilities.collections.CollectionExtensionsKt; import com.discord.utilities.persister.Persister; import com.discord.utilities.search.network.state.SearchState; import d0.d0.f; import d0.t.g0; import d0.t.h0; import d0.t.n; import d0.t.o; import d0.t.r; import d0.t.u; import d0.z.d.m; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import rx.Observable; /* compiled from: StoreChannels.kt */ public final class StoreChannels extends StoreV2 { public static final Companion Companion = new Companion(null); private static final StoreChannels$Companion$InitializedUpdateSource$1 InitializedUpdateSource = new StoreChannels$Companion$InitializedUpdateSource$1(); public static final long PRIVATE_CHANNELS_ID = 0; private final Map channelNames; private Map channelNamesSnapshot; private final Map> channelsByGuild; private Map> channelsByGuildSnapshot; private Map channelsByIdSnapshot; private final Persister> channelsCache; private final Dispatcher dispatcher; private final Function0> getLurkingGuildIds; private boolean handledReadyPayload; private boolean initializedForAuthedUser; private final Function0 isAuthenticated; private boolean isConnectionOpen; private boolean isStoreInitTimedOut; private final ObservationDeck observationDeck; private final Function1>> observeChannelPermissionsForGuild; private final Map preloadedThreads; private final Map threadsById; private Map threadsByIdSnapshot; /* compiled from: StoreChannels.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } } /* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: kotlin.jvm.functions.Function1>> */ /* JADX DEBUG: Multi-variable search result rejected for r5v0, resolved type: kotlin.jvm.functions.Function0> */ /* JADX WARN: Multi-variable type inference failed */ public StoreChannels(Dispatcher dispatcher, ObservationDeck observationDeck, Function1>> function1, Function0> function0, Function0 function02, Persister> persister) { m.checkNotNullParameter(dispatcher, "dispatcher"); m.checkNotNullParameter(observationDeck, "observationDeck"); m.checkNotNullParameter(function1, "observeChannelPermissionsForGuild"); m.checkNotNullParameter(function0, "getLurkingGuildIds"); m.checkNotNullParameter(function02, "isAuthenticated"); m.checkNotNullParameter(persister, "channelsCache"); this.dispatcher = dispatcher; this.observationDeck = observationDeck; this.observeChannelPermissionsForGuild = function1; this.getLurkingGuildIds = function0; this.isAuthenticated = function02; this.channelsCache = persister; this.channelsByIdSnapshot = new HashMap(); this.channelNamesSnapshot = new HashMap(); this.channelNames = new HashMap(); this.channelsByGuildSnapshot = h0.emptyMap(); HashMap hashMap = new HashMap(); this.channelsByGuild = hashMap; this.threadsByIdSnapshot = new HashMap(); this.threadsById = new HashMap(); this.preloadedThreads = new HashMap(); hashMap.put(0L, new HashMap()); } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ StoreChannels(Dispatcher dispatcher, ObservationDeck observationDeck, Function1 function1, Function0 function0, Function0 function02, Persister persister, int i, DefaultConstructorMarker defaultConstructorMarker) { this(dispatcher, observationDeck, function1, function0, function02, (i & 32) != 0 ? new Persister("STORE_CHANNELS_V26", new ArrayList()) : persister); } public static final /* synthetic */ Map access$getChannelNamesSnapshot$p(StoreChannels storeChannels) { return storeChannels.channelNamesSnapshot; } public static final /* synthetic */ Map access$getChannelsByIdSnapshot$p(StoreChannels storeChannels) { return storeChannels.channelsByIdSnapshot; } public static final /* synthetic */ Map access$getThreadsByIdSnapshot$p(StoreChannels storeChannels) { return storeChannels.threadsByIdSnapshot; } public static final /* synthetic */ void access$setChannelNamesSnapshot$p(StoreChannels storeChannels, Map map) { storeChannels.channelNamesSnapshot = map; } public static final /* synthetic */ void access$setChannelsByIdSnapshot$p(StoreChannels storeChannels, Map map) { storeChannels.channelsByIdSnapshot = map; } public static final /* synthetic */ void access$setThreadsByIdSnapshot$p(StoreChannels storeChannels, Map map) { storeChannels.threadsByIdSnapshot = map; } public static /* synthetic */ Observable observeChannelsForGuild$default(StoreChannels storeChannels, long j, Integer num, int i, Object obj) { if ((i & 2) != 0) { num = null; } return storeChannels.observeChannelsForGuild(j, num); } public static /* synthetic */ Observable observeIds$default(StoreChannels storeChannels, boolean z2, int i, Object obj) { if ((i & 1) != 0) { z2 = false; } return storeChannels.observeIds(z2); } public static /* synthetic */ void storeThread$app_productionBetaRelease$default(StoreChannels storeChannels, Channel channel, long j, Channel channel2, int i, Object obj) { if ((i & 2) != 0) { j = 0; } if ((i & 4) != 0) { channel2 = null; } storeChannels.storeThread$app_productionBetaRelease(channel, j, channel2); } @StoreThread private final void updateInitializationState() { boolean z2 = this.initializedForAuthedUser; boolean z3 = this.isAuthenticated.mo1invoke().booleanValue() && ((getChannelsByIdInternal$app_productionBetaRelease().isEmpty() ^ true) || this.handledReadyPayload || this.isStoreInitTimedOut); if (!z2 && z3) { this.initializedForAuthedUser = true; markChanged(InitializedUpdateSource); } } public final Channel findChannelById(long j) { if (this.threadsByIdSnapshot.containsKey(Long.valueOf(j))) { return this.threadsByIdSnapshot.get(Long.valueOf(j)); } Iterator it = this.channelsByGuildSnapshot.values().iterator(); while (it.hasNext()) { Map map = (Map) it.next(); if (map.containsKey(Long.valueOf(j))) { return (Channel) map.get(Long.valueOf(j)); } } return null; } @StoreThread public final Channel findChannelByIdInternal$app_productionBetaRelease(long j) { if (this.threadsById.containsKey(Long.valueOf(j))) { return this.threadsById.get(Long.valueOf(j)); } Iterator it = this.channelsByGuild.values().iterator(); while (it.hasNext()) { Map map = (Map) it.next(); if (map.containsKey(Long.valueOf(j))) { return (Channel) map.get(Long.valueOf(j)); } } return null; } @StoreThread public final List findChannelsByCategoryInternal$app_productionBetaRelease(long j, long j2) { Collection values; Map map = this.channelsByGuild.get(Long.valueOf(j)); if (map == null || (values = map.values()) == null) { return n.emptyList(); } ArrayList arrayList = new ArrayList(); for (Object obj : values) { if (((Channel) obj).r() == j2) { arrayList.add(obj); } } return arrayList; } public final Channel getChannel(long j) { Channel channel = this.channelsByIdSnapshot.get(Long.valueOf(j)); return channel != null ? channel : this.threadsByIdSnapshot.get(Long.valueOf(j)); } @StoreThread public final Channel getChannelInternal$app_productionBetaRelease(long j, long j2) { Channel channel; Map map = this.channelsByGuild.get(Long.valueOf(j)); return (map == null || (channel = map.get(Long.valueOf(j2))) == null) ? this.threadsById.get(Long.valueOf(j2)) : channel; } public final Map getChannelNames() { return this.channelNamesSnapshot; } @StoreThread public final Map getChannelNamesInternal$app_productionBetaRelease() { return this.channelNames; } @StoreThread public final Map> getChannelsByGuildInternal$app_productionBetaRelease() { return this.channelsByGuild; } @StoreThread public final Map getChannelsByIdInternal$app_productionBetaRelease() { Collection> values = this.channelsByGuild.values(); ArrayList arrayList = new ArrayList(); Iterator it = values.iterator(); while (it.hasNext()) { r.addAll(arrayList, ((Map) it.next()).values()); } LinkedHashMap linkedHashMap = new LinkedHashMap(f.coerceAtLeast(g0.mapCapacity(o.collectionSizeOrDefault(arrayList, 10)), 16)); for (Object obj : arrayList) { linkedHashMap.put(Long.valueOf(((Channel) obj).h()), obj); } return linkedHashMap; } public final Map getChannelsForGuild(long j) { Map map = (Map) this.channelsByGuildSnapshot.get(Long.valueOf(j)); return map != null ? map : h0.emptyMap(); } @StoreThread public final Map getChannelsForGuildInternal$app_productionBetaRelease(long j) { return this.channelsByGuild.get(Long.valueOf(j)); } @StoreThread public final Channel getGuildChannelInternal$app_productionBetaRelease(long j, long j2) { Map map = this.channelsByGuild.get(Long.valueOf(j)); if (map != null) { return map.get(Long.valueOf(j2)); } return null; } public final boolean getInitializedForAuthedUser$app_productionBetaRelease() { return this.initializedForAuthedUser; } @StoreThread public final Map getThreadsByIdInternal$app_productionBetaRelease() { return this.threadsById; } @StoreThread public final List getThreadsForChannelInternal$app_productionBetaRelease(long j) { Collection values = this.threadsById.values(); ArrayList arrayList = new ArrayList(); for (Object obj : values) { if (((Channel) obj).r() == j) { arrayList.add(obj); } } return arrayList; } @StoreThread public final List getThreadsForGuildInternal$app_productionBetaRelease(long j) { Collection values = this.threadsById.values(); ArrayList arrayList = new ArrayList(); for (Object obj : values) { if (((Channel) obj).f() == j) { arrayList.add(obj); } } return arrayList; } @StoreThread public final void handleChannelOrThreadCreateOrUpdate(Channel channel) { m.checkNotNullParameter(channel, "channel"); if (!ChannelUtils.v(channel)) { long f = !ChannelUtils.x(channel) ? channel.f() : 0; long h = channel.h(); if (ChannelUtils.C(channel)) { storeThread$app_productionBetaRelease$default(this, channel, f, null, 4, null); } else { Map> map = this.channelsByGuild; Long valueOf = Long.valueOf(f); Map map2 = map.get(valueOf); if (map2 == null) { map2 = new HashMap<>(); map.put(valueOf, map2); } Map map3 = map2; Channel channel2 = map3.get(Long.valueOf(h)); if (!m.areEqual(channel, channel2)) { if (channel2 != null) { map3.put(Long.valueOf(h), Channel.a(channel, null, 0, channel.f() != 0 ? channel.f() : f, null, 0, 0, 0, null, channel2.w(), 0, null, 0, 0, null, 0, 0, null, false, 0, null, 0, null, null, null, null, null, null, null, null, 536870651)); } else { map3.put(Long.valueOf(h), Channel.a(channel, null, 0, channel.f() != 0 ? channel.f() : f, null, 0, 0, 0, null, null, 0, null, 0, 0, null, 0, 0, null, false, 0, null, 0, null, null, null, null, null, null, null, null, 536870907)); } } boolean o = channel.o(); if (channel2 == null || o != channel2.o()) { for (Channel channel3 : getThreadsForChannelInternal$app_productionBetaRelease(channel.h())) { storeThread$app_productionBetaRelease(channel3, f, channel); } } this.channelNames.put(Long.valueOf(h), ChannelUtils.c(channel)); } markChanged(); } } @StoreThread public final void handleChannelOrThreadDelete(Channel channel) { Map map; m.checkNotNullParameter(channel, "channel"); long f = !ChannelUtils.x(channel) ? channel.f() : 0; long h = channel.h(); if (this.channelsByGuild.containsKey(Long.valueOf(f)) && (map = this.channelsByGuild.get(Long.valueOf(f))) != null && map.containsKey(Long.valueOf(h))) { Map map2 = this.channelsByGuild.get(Long.valueOf(f)); if (map2 != null) { map2.remove(Long.valueOf(h)); } markChanged(); } if (this.channelNames.containsKey(Long.valueOf(h))) { this.channelNames.remove(Long.valueOf(h)); markChanged(); } if (this.threadsById.containsKey(Long.valueOf(h))) { this.threadsById.remove(Long.valueOf(h)); markChanged(); } } @StoreThread public final void handleConnected(boolean z2) { this.isConnectionOpen = z2; } /* JADX DEBUG: Multi-variable search result rejected for r2v4, resolved type: java.util.Map */ /* JADX WARN: Multi-variable type inference failed */ @StoreThread public final void handleConnectionOpen(ModelPayload modelPayload) { m.checkNotNullParameter(modelPayload, "payload"); this.isConnectionOpen = true; this.channelsByGuild.clear(); this.channelNames.clear(); this.threadsById.clear(); Map> map = this.channelsByGuild; Map map2 = map.get(0L); if (map2 == null) { map2 = new HashMap<>(); map.put(0L, map2); } Map map3 = map2; List privateChannels = modelPayload.getPrivateChannels(); ArrayList Y = a.Y(privateChannels, "payload.privateChannels"); for (Object obj : privateChannels) { Channel channel = (Channel) obj; m.checkNotNullExpressionValue(channel, "it"); if (!ChannelUtils.v(channel)) { Y.add(obj); } } for (Channel channel2 : Y) { Long valueOf = Long.valueOf(channel2.h()); m.checkNotNullExpressionValue(channel2, "privateChannel"); map3.put(valueOf, channel2); } List guilds = modelPayload.getGuilds(); m.checkNotNullExpressionValue(guilds, "payload.guilds"); for (Guild guild : guilds) { Map> map4 = this.channelsByGuild; Long valueOf2 = Long.valueOf(guild.q()); Map map5 = map4.get(valueOf2); if (map5 == null) { map5 = new HashMap<>(); map4.put(valueOf2, map5); } Map map6 = map5; List g = guild.g(); if (g != null) { for (Channel channel3 : g) { map6.put(Long.valueOf(channel3.h()), Channel.a(channel3, null, 0, channel3.f() != 0 ? channel3.f() : guild.q(), null, 0, 0, 0, null, null, 0, null, 0, 0, null, 0, 0, null, false, 0, null, 0, null, null, null, null, null, null, null, null, 536870907)); } } List M = guild.M(); if (M != null) { for (Channel channel4 : M) { if (ChannelUtils.C(channel4)) { storeThread$app_productionBetaRelease$default(this, channel4, guild.q(), null, 4, null); } } } } for (Channel channel5 : this.preloadedThreads.values()) { if (!this.threadsById.containsKey(Long.valueOf(channel5.h()))) { storeThread$app_productionBetaRelease$default(this, channel5, channel5.f(), null, 4, null); } } this.preloadedThreads.clear(); for (Map.Entry> entry : this.channelsByGuild.entrySet()) { Map map7 = this.channelNames; Iterator it = entry.getValue().entrySet().iterator(); while (it.hasNext()) { Map.Entry entry2 = (Map.Entry) it.next(); map7.put(entry2.getKey(), ChannelUtils.c((Channel) entry2.getValue())); } } this.handledReadyPayload = true; updateInitializationState(); markChanged(); } /* JADX WARNING: Removed duplicated region for block: B:42:0x012d */ @StoreThread public final void handleGroupDMRecipient(ChannelRecipient channelRecipient, boolean z2) { ArrayList arrayList; ArrayList arrayList2; Map map; ArrayList arrayList3; m.checkNotNullParameter(channelRecipient, "recipient"); Map map2 = this.channelsByGuild.get(0L); if (map2 != null) { long a = channelRecipient.a(); Channel channel = map2.get(Long.valueOf(a)); if (channel != null) { long f = channel.f(); if (z2) { List w = channel.w(); ArrayList arrayList4 = w != null ? new ArrayList(w) : new ArrayList(); arrayList4.add(channelRecipient.c()); arrayList = arrayList4; } else { ArrayList arrayList5 = new ArrayList(); List w2 = channel.w(); if (w2 == null) { w2 = n.emptyList(); } for (User user : w2) { if (user.i() != channelRecipient.c().i()) { arrayList5.add(user); } } arrayList = arrayList5; } long f2 = channel.f() != 0 ? channel.f() : f; String b = channelRecipient.b(); if (b != null) { List n = channel.n(); if (n != null) { arrayList3 = new ArrayList(o.collectionSizeOrDefault(n, 10)); for (ChannelRecipientNick channelRecipientNick : n) { if (channelRecipientNick.b() == channelRecipient.c().i()) { channelRecipientNick = new ChannelRecipientNick(channelRecipient.c().i(), b); } arrayList3.add(channelRecipientNick); } } else { arrayList3 = null; } if (arrayList3 != null) { arrayList2 = arrayList3; Channel a2 = Channel.a(channel, null, 0, f2, null, 0, 0, 0, null, arrayList, 0, null, 0, 0, null, 0, 0, arrayList2, false, 0, null, 0, null, null, null, null, null, null, null, null, 536805115); map = this.channelsByGuild.get(Long.valueOf(f)); if (map != null) { map.put(Long.valueOf(a), a2); } markChanged(); } } arrayList2 = channel.n(); Channel a2 = Channel.a(channel, null, 0, f2, null, 0, 0, 0, null, arrayList, 0, null, 0, 0, null, 0, 0, arrayList2, false, 0, null, 0, null, null, null, null, null, null, null, null, 536805115); map = this.channelsByGuild.get(Long.valueOf(f)); if (map != null) { } markChanged(); } } } @StoreThread public final void handleGuildAdd(Guild guild) { m.checkNotNullParameter(guild, "guild"); Map> map = this.channelsByGuild; Long valueOf = Long.valueOf(guild.q()); Map map2 = map.get(valueOf); if (map2 == null) { map2 = new HashMap<>(); map.put(valueOf, map2); } Map map3 = map2; List g = guild.g(); if (g != null) { for (Channel channel : g) { map3.put(Long.valueOf(channel.h()), Channel.a(channel, null, 0, channel.f() != 0 ? channel.f() : guild.q(), null, 0, 0, 0, null, null, 0, null, 0, 0, null, 0, 0, null, false, 0, null, 0, null, null, null, null, null, null, null, null, 536870907)); this.channelNames.put(Long.valueOf(channel.h()), ChannelUtils.c(channel)); } } List M = guild.M(); if (M != null) { for (Channel channel2 : M) { if (ChannelUtils.C(channel2)) { storeThread$app_productionBetaRelease$default(this, channel2, guild.q(), null, 4, null); } } } markChanged(); } @StoreThread public final void handleGuildRemove(Guild guild) { Set keySet; m.checkNotNullParameter(guild, "guild"); long q = guild.q(); if (this.channelsByGuild.containsKey(Long.valueOf(q))) { Map map = this.channelsByGuild.get(Long.valueOf(q)); if (!(map == null || (keySet = map.keySet()) == null)) { for (Number number : keySet) { this.channelNames.remove(Long.valueOf(number.longValue())); } } this.channelsByGuild.remove(Long.valueOf(guild.q())); r.removeAll(this.threadsById.values(), new StoreChannels$handleGuildRemove$2(guild)); } markChanged(); } @StoreThread public final void handleMessagesLoaded(List list) { m.checkNotNullParameter(list, "messages"); for (Message message : list) { Channel thread = message.getThread(); if (thread != null) { if (!this.threadsById.containsKey(Long.valueOf(thread.h())) && ChannelUtils.C(thread)) { storeThread$app_productionBetaRelease$default(this, thread, 0, null, 6, null); markChanged(); } if (!this.isConnectionOpen) { this.preloadedThreads.put(Long.valueOf(thread.h()), thread); } } } } @StoreThread public final void handleSearchFinish(SearchState searchState) { m.checkNotNullParameter(searchState, "searchState"); List threads = searchState.getThreads(); if (threads != null) { for (Channel channel : threads) { if (!this.threadsById.containsKey(Long.valueOf(channel.h())) && ChannelUtils.C(channel)) { storeThread$app_productionBetaRelease$default(this, channel, 0, null, 6, null); markChanged(); } } } List hits = searchState.getHits(); if (hits != null) { for (Message message : hits) { Channel thread = message.getThread(); if (thread != null && !this.threadsById.containsKey(Long.valueOf(thread.h())) && ChannelUtils.C(thread)) { storeThread$app_productionBetaRelease$default(this, thread, 0, null, 6, null); markChanged(); } } } } @StoreThread public final void handleStoreInitTimeout() { this.isStoreInitTimedOut = true; updateInitializationState(); } @StoreThread public final void handleThreadCreateOrUpdate(Channel channel) { m.checkNotNullParameter(channel, "channel"); if (ChannelUtils.C(channel)) { handleChannelOrThreadCreateOrUpdate(channel); } } @StoreThread public final void handleThreadListSync(ModelThreadListSync modelThreadListSync) { m.checkNotNullParameter(modelThreadListSync, "payload"); if (!modelThreadListSync.getThreads().isEmpty()) { for (Channel channel : modelThreadListSync.getThreads()) { if (ChannelUtils.C(channel)) { storeThread$app_productionBetaRelease$default(this, channel, modelThreadListSync.getGuildId(), null, 4, null); } } markChanged(); } } @StoreThread public final void init() { List filterNotNull = u.filterNotNull(this.channelsCache.get()); Map> map = this.channelsByGuild; LinkedHashMap linkedHashMap = new LinkedHashMap(); for (Object obj : filterNotNull) { Long valueOf = Long.valueOf(((Channel) obj).f()); Object obj2 = linkedHashMap.get(valueOf); if (obj2 == null) { obj2 = new ArrayList(); linkedHashMap.put(valueOf, obj2); } ((List) obj2).add(obj); } LinkedHashMap linkedHashMap2 = new LinkedHashMap(g0.mapCapacity(linkedHashMap.size())); for (Map.Entry entry : linkedHashMap.entrySet()) { Object key = entry.getKey(); HashMap hashMap = new HashMap(); for (Object obj3 : (List) entry.getValue()) { hashMap.put(Long.valueOf(((Channel) obj3).h()), obj3); } linkedHashMap2.put(key, hashMap); } map.putAll(linkedHashMap2); updateInitializationState(); markChanged(); } public final Observable> observeAllChannels() { return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannels$observeAllChannels$1(this), 14, null); } public final Observable observeChannel(long j) { Observable q = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannels$observeChannel$1(this, j), 14, null).q(); m.checkNotNullExpressionValue(q, "observationDeck\n … .distinctUntilChanged()"); return q; } public final Observable> observeChannelCategories(long j) { Observable> q = observeChannelsForGuild$default(this, j, null, 2, null).F(StoreChannels$observeChannelCategories$1.INSTANCE).q(); m.checkNotNullExpressionValue(q, "observeChannelsForGuild(… .distinctUntilChanged()"); return q; } public final Observable> observeChannelsForGuild(long j) { return observeChannelsForGuild$default(this, j, null, 2, null); } public final Observable> observeChannelsForGuild(long j, Integer num) { Observable> q = observeGuildAndPrivateChannels().Y(new StoreChannels$observeChannelsForGuild$1(j, num)).q(); m.checkNotNullExpressionValue(q, "observeGuildAndPrivateCh… .distinctUntilChanged()"); return q; } public final Observable> observeDMs() { Observable F = observePrivateChannels().F(StoreChannels$observeDMs$1.INSTANCE); m.checkNotNullExpressionValue(F, "observePrivateChannels()…nel -> channel.isDM() } }"); return F; } public final Observable observeDefaultChannel(long j) { Observable q = this.observeChannelPermissionsForGuild.invoke(Long.valueOf(j)).Y(new StoreChannels$observeDefaultChannel$1(this, j)).q(); m.checkNotNullExpressionValue(q, "observeChannelPermission… .distinctUntilChanged()"); return q; } public final Observable> observeDirectShareCandidates(Context context) { m.checkNotNullParameter(context, "context"); Observable F = observeGuildAndPrivateChannels().x(StoreChannels$observeDirectShareCandidates$1.INSTANCE).F(new StoreChannels$observeDirectShareCandidates$2(context)); m.checkNotNullExpressionValue(F, "observeGuildAndPrivateCh…ity(context))\n }"); return F; } public final Observable> observeGuildAndPrivateChannels() { return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannels$observeGuildAndPrivateChannels$1(this), 14, null); } public final Observable>> observeIds(boolean z2) { Observable>> q = (z2 ? observeAllChannels() : observeGuildAndPrivateChannels()).F(StoreChannels$observeIds$1.INSTANCE).q(); m.checkNotNullExpressionValue(q, "channelsObservable\n … .distinctUntilChanged()"); return q; } public final Observable observeInitializedForAuthedUser() { return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{InitializedUpdateSource}, false, null, null, new StoreChannels$observeInitializedForAuthedUser$1(this), 14, null); } public final Observable> observeNames() { Observable> q = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannels$observeNames$1(this), 14, null).q(); m.checkNotNullExpressionValue(q, "observationDeck\n … .distinctUntilChanged()"); return q; } public final Observable> observeNames(Collection collection) { m.checkNotNullParameter(collection, "channelIds"); Observable k = observeNames().k(c.a.d.o.a(collection)); m.checkNotNullExpressionValue(k, "observeNames().compose(A…rs.filterMap(channelIds))"); return k; } public final Observable observePrivateChannel(long j) { Observable q = observePrivateChannels().F(new StoreChannels$observePrivateChannel$1(j)).q(); m.checkNotNullExpressionValue(q, "observePrivateChannels()… .distinctUntilChanged()"); return q; } public final Observable> observePrivateChannels() { return observeChannelsForGuild$default(this, 0, null, 2, null); } public final Observable> observeThreadsFromMessages(List list) { m.checkNotNullParameter(list, "messages"); Observable> q = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannels$observeThreadsFromMessages$1(this, list), 14, null).q(); m.checkNotNullExpressionValue(q, "observationDeck\n … .distinctUntilChanged()"); return q; } public final void onGroupCreated(Channel channel) { m.checkNotNullParameter(channel, "channel"); this.dispatcher.schedule(new StoreChannels$onGroupCreated$1(this, channel)); } public final void setInitializedForAuthedUser$app_productionBetaRelease(boolean z2) { this.initializedForAuthedUser = z2; } @Override // com.discord.stores.StoreV2 @StoreThread public void snapshotData() { Collection> values = this.channelsByGuild.values(); ArrayList arrayList = new ArrayList(); Iterator it = values.iterator(); while (it.hasNext()) { r.addAll(arrayList, ((Map) it.next()).values()); } ArrayList arrayList2 = new ArrayList(); Iterator it2 = this.getLurkingGuildIds.mo1invoke().iterator(); while (true) { Set set = null; if (!it2.hasNext()) { break; } Map map = this.channelsByGuild.get(Long.valueOf(((Number) it2.next()).longValue())); if (map != null) { set = map.keySet(); } if (set != null) { arrayList2.add(set); } } List flatten = o.flatten(arrayList2); Persister> persister = this.channelsCache; ArrayList arrayList3 = new ArrayList(); for (Object obj : arrayList) { if (!flatten.contains(Long.valueOf(((Channel) obj).h()))) { arrayList3.add(obj); } } Persister.set$default(persister, arrayList3, false, 2, null); LinkedHashMap linkedHashMap = new LinkedHashMap(f.coerceAtLeast(g0.mapCapacity(o.collectionSizeOrDefault(arrayList, 10)), 16)); for (Object obj2 : arrayList) { linkedHashMap.put(Long.valueOf(((Channel) obj2).h()), obj2); } this.channelsByIdSnapshot = linkedHashMap; Map> map2 = this.channelsByGuild; LinkedHashMap linkedHashMap2 = new LinkedHashMap(g0.mapCapacity(map2.size())); Iterator it3 = map2.entrySet().iterator(); while (it3.hasNext()) { Map.Entry entry = (Map.Entry) it3.next(); linkedHashMap2.put(entry.getKey(), CollectionExtensionsKt.snapshot$default((Map) entry.getValue(), 0, 0.0f, 3, null)); } this.channelsByGuildSnapshot = linkedHashMap2; this.channelNamesSnapshot = CollectionExtensionsKt.snapshot$default(this.channelNames, 0, 0.0f, 3, null); this.threadsByIdSnapshot = CollectionExtensionsKt.snapshot$default(this.threadsById, 0, 0.0f, 3, null); } /* JADX WARNING: Removed duplicated region for block: B:12:0x003e */ /* JADX WARNING: Removed duplicated region for block: B:13:0x0043 */ @StoreThread public final void storeThread$app_productionBetaRelease(Channel channel, long j, Channel channel2) { Boolean bool; boolean o; m.checkNotNullParameter(channel, "thread"); long f = channel.f() != 0 ? channel.f() : j; if (channel2 != null) { o = channel2.o(); } else { Channel channelInternal$app_productionBetaRelease = getChannelInternal$app_productionBetaRelease(channel.f(), channel.r()); if (channelInternal$app_productionBetaRelease != null) { o = channelInternal$app_productionBetaRelease.o(); } else { bool = null; this.threadsById.put(Long.valueOf(channel.h()), Channel.a(channel, null, 0, f, null, 0, 0, 0, null, null, 0, null, 0, 0, null, 0, 0, null, bool == null ? bool.booleanValue() : channel.o(), 0, null, 0, null, null, null, null, null, null, null, null, 536739835)); this.channelNames.put(Long.valueOf(channel.h()), ChannelUtils.c(channel)); } } bool = Boolean.valueOf(o); this.threadsById.put(Long.valueOf(channel.h()), Channel.a(channel, null, 0, f, null, 0, 0, 0, null, null, 0, null, 0, 0, null, 0, 0, null, bool == null ? bool.booleanValue() : channel.o(), 0, null, 0, null, null, null, null, null, null, null, null, 536739835)); this.channelNames.put(Long.valueOf(channel.h()), ChannelUtils.c(channel)); } }