856 lines
38 KiB
Java
856 lines
38 KiB
Java
package com.discord.stores;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import c.d.b.a.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.guild.Guild;
|
|
import com.discord.models.domain.ModelPayload;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.utilities.frecency.FrecencyTracker;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.utilities.persister.Persister;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.widgets.user.search.ChannelFrecencyTracker;
|
|
import d0.t.g0;
|
|
import d0.t.h0;
|
|
import d0.t.n0;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
import rx.Subscription;
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public final class StoreChannelsSelected extends StoreV2 {
|
|
private static final String CACHE_KEY_SELECTED_CHANNEL_IDS = "CACHE_KEY_SELECTED_CHANNEL_IDS";
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final long ID_THREAD_DRAFT = -3;
|
|
public static final long ID_UNAVAILABLE = -1;
|
|
public static final long ID_UNINITIALIZED = -2;
|
|
public static final long ID_UNSELECTED = 0;
|
|
private static final StoreChannelsSelected$Companion$InitializedUpdateSource$1 InitializedUpdateSource = new StoreChannelsSelected$Companion$InitializedUpdateSource$1();
|
|
private final Dispatcher dispatcher;
|
|
private final ChannelFrecencyTracker frecency;
|
|
private final Persister<ChannelFrecencyTracker> frecencyCache;
|
|
private boolean handledReadyPayload;
|
|
private boolean initializedForAuthedUser;
|
|
private boolean isStoreInitTimedOut;
|
|
private final ObservationDeck observationDeck;
|
|
private ResolvedSelectedChannel previouslySelectedChannel;
|
|
private ResolvedSelectedChannel selectedChannel;
|
|
private final Persister<Map<Long, Long>> selectedChannelIdsCache = new Persister<>("CACHE_KEY_SELECTED_CHANNEL_IDS", new HashMap());
|
|
private final StoreChannels storeChannels;
|
|
private final StoreGuildSelected storeGuildSelected;
|
|
private final StorePermissions storePermissions;
|
|
private final StoreStream stream;
|
|
private final Map<Long, UserChannelSelection> userChannelSelections = new HashMap();
|
|
private Subscription validateSelectedChannelSubscription;
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static abstract class ResolvedSelectedChannel {
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class Channel extends ResolvedSelectedChannel {
|
|
private final SelectedChannelAnalyticsLocation analyticsLocation;
|
|
private final ChannelAnalyticsViewType analyticsViewType;
|
|
private final com.discord.api.channel.Channel channel;
|
|
private final Long peekParent;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Channel(com.discord.api.channel.Channel channel, Long l, SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation) {
|
|
super(null);
|
|
m.checkNotNullParameter(channel, "channel");
|
|
this.channel = channel;
|
|
this.peekParent = l;
|
|
this.analyticsLocation = selectedChannelAnalyticsLocation;
|
|
this.analyticsViewType = l != null ? ChannelAnalyticsViewType.PEEK_VIEW : ChannelAnalyticsViewType.FULL_VIEW;
|
|
}
|
|
|
|
public static /* synthetic */ Channel copy$default(Channel channel, com.discord.api.channel.Channel channel2, Long l, SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
channel2 = channel.channel;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
l = channel.peekParent;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
selectedChannelAnalyticsLocation = channel.analyticsLocation;
|
|
}
|
|
return channel.copy(channel2, l, selectedChannelAnalyticsLocation);
|
|
}
|
|
|
|
public final com.discord.api.channel.Channel component1() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Long component2() {
|
|
return this.peekParent;
|
|
}
|
|
|
|
public final SelectedChannelAnalyticsLocation component3() {
|
|
return this.analyticsLocation;
|
|
}
|
|
|
|
public final Channel copy(com.discord.api.channel.Channel channel, Long l, SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
return new Channel(channel, l, selectedChannelAnalyticsLocation);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Channel)) {
|
|
return false;
|
|
}
|
|
Channel channel = (Channel) obj;
|
|
return m.areEqual(this.channel, channel.channel) && m.areEqual(this.peekParent, channel.peekParent) && m.areEqual(this.analyticsLocation, channel.analyticsLocation);
|
|
}
|
|
|
|
public final SelectedChannelAnalyticsLocation getAnalyticsLocation() {
|
|
return this.analyticsLocation;
|
|
}
|
|
|
|
public final ChannelAnalyticsViewType getAnalyticsViewType() {
|
|
return this.analyticsViewType;
|
|
}
|
|
|
|
public final com.discord.api.channel.Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Long getPeekParent() {
|
|
return this.peekParent;
|
|
}
|
|
|
|
public int hashCode() {
|
|
com.discord.api.channel.Channel channel = this.channel;
|
|
int i = 0;
|
|
int hashCode = (channel != null ? channel.hashCode() : 0) * 31;
|
|
Long l = this.peekParent;
|
|
int hashCode2 = (hashCode + (l != null ? l.hashCode() : 0)) * 31;
|
|
SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation = this.analyticsLocation;
|
|
if (selectedChannelAnalyticsLocation != null) {
|
|
i = selectedChannelAnalyticsLocation.hashCode();
|
|
}
|
|
return hashCode2 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("Channel(channel=");
|
|
K.append(this.channel);
|
|
K.append(", peekParent=");
|
|
K.append(this.peekParent);
|
|
K.append(", analyticsLocation=");
|
|
K.append(this.analyticsLocation);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class ThreadDraft extends ResolvedSelectedChannel {
|
|
private final com.discord.api.channel.Channel parentChannel;
|
|
private final Long starterMessageId;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public ThreadDraft(com.discord.api.channel.Channel channel, Long l) {
|
|
super(null);
|
|
m.checkNotNullParameter(channel, "parentChannel");
|
|
this.parentChannel = channel;
|
|
this.starterMessageId = l;
|
|
}
|
|
|
|
public static /* synthetic */ ThreadDraft copy$default(ThreadDraft threadDraft, com.discord.api.channel.Channel channel, Long l, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
channel = threadDraft.parentChannel;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
l = threadDraft.starterMessageId;
|
|
}
|
|
return threadDraft.copy(channel, l);
|
|
}
|
|
|
|
public final com.discord.api.channel.Channel component1() {
|
|
return this.parentChannel;
|
|
}
|
|
|
|
public final Long component2() {
|
|
return this.starterMessageId;
|
|
}
|
|
|
|
public final ThreadDraft copy(com.discord.api.channel.Channel channel, Long l) {
|
|
m.checkNotNullParameter(channel, "parentChannel");
|
|
return new ThreadDraft(channel, l);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ThreadDraft)) {
|
|
return false;
|
|
}
|
|
ThreadDraft threadDraft = (ThreadDraft) obj;
|
|
return m.areEqual(this.parentChannel, threadDraft.parentChannel) && m.areEqual(this.starterMessageId, threadDraft.starterMessageId);
|
|
}
|
|
|
|
public final com.discord.api.channel.Channel getParentChannel() {
|
|
return this.parentChannel;
|
|
}
|
|
|
|
public final Long getStarterMessageId() {
|
|
return this.starterMessageId;
|
|
}
|
|
|
|
public final boolean hasStarterMessage() {
|
|
return this.starterMessageId != null;
|
|
}
|
|
|
|
public int hashCode() {
|
|
com.discord.api.channel.Channel channel = this.parentChannel;
|
|
int i = 0;
|
|
int hashCode = (channel != null ? channel.hashCode() : 0) * 31;
|
|
Long l = this.starterMessageId;
|
|
if (l != null) {
|
|
i = l.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ThreadDraft(parentChannel=");
|
|
K.append(this.parentChannel);
|
|
K.append(", starterMessageId=");
|
|
return a.A(K, this.starterMessageId, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class Unavailable extends ResolvedSelectedChannel {
|
|
public static final Unavailable INSTANCE = new Unavailable();
|
|
|
|
private Unavailable() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class Uninitialized extends ResolvedSelectedChannel {
|
|
public static final Uninitialized INSTANCE = new Uninitialized();
|
|
|
|
private Uninitialized() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class Unselected extends ResolvedSelectedChannel {
|
|
public static final Unselected INSTANCE = new Unselected();
|
|
|
|
private Unselected() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
private ResolvedSelectedChannel() {
|
|
}
|
|
|
|
public /* synthetic */ ResolvedSelectedChannel(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final com.discord.api.channel.Channel getChannelOrParent() {
|
|
if (this instanceof Channel) {
|
|
return ((Channel) this).getChannel();
|
|
}
|
|
if (this instanceof ThreadDraft) {
|
|
return ((ThreadDraft) this).getParentChannel();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public final long getId() {
|
|
if (this instanceof Channel) {
|
|
return ((Channel) this).getChannel().h();
|
|
}
|
|
if (this instanceof ThreadDraft) {
|
|
return -3;
|
|
}
|
|
if (m.areEqual(this, Unselected.INSTANCE)) {
|
|
return 0;
|
|
}
|
|
if (m.areEqual(this, Unavailable.INSTANCE)) {
|
|
return -1;
|
|
}
|
|
if (m.areEqual(this, Uninitialized.INSTANCE)) {
|
|
return -2;
|
|
}
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
|
|
public final com.discord.api.channel.Channel getMaybeChannel() {
|
|
Channel channel = (Channel) (!(this instanceof Channel) ? null : this);
|
|
if (channel != null) {
|
|
return channel.getChannel();
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static abstract class UserChannelSelection {
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class SelectedChannel extends UserChannelSelection {
|
|
private final SelectedChannelAnalyticsLocation analyticsLocation;
|
|
private final long channelId;
|
|
private final Long peekParent;
|
|
|
|
public SelectedChannel(long j, Long l, SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation) {
|
|
super(null);
|
|
this.channelId = j;
|
|
this.peekParent = l;
|
|
this.analyticsLocation = selectedChannelAnalyticsLocation;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ SelectedChannel(long j, Long l, SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, (i & 2) != 0 ? null : l, (i & 4) != 0 ? null : selectedChannelAnalyticsLocation);
|
|
}
|
|
|
|
public static /* synthetic */ SelectedChannel copy$default(SelectedChannel selectedChannel, long j, Long l, SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = selectedChannel.channelId;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
l = selectedChannel.peekParent;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
selectedChannelAnalyticsLocation = selectedChannel.analyticsLocation;
|
|
}
|
|
return selectedChannel.copy(j, l, selectedChannelAnalyticsLocation);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final Long component2() {
|
|
return this.peekParent;
|
|
}
|
|
|
|
public final SelectedChannelAnalyticsLocation component3() {
|
|
return this.analyticsLocation;
|
|
}
|
|
|
|
public final SelectedChannel copy(long j, Long l, SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation) {
|
|
return new SelectedChannel(j, l, selectedChannelAnalyticsLocation);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof SelectedChannel)) {
|
|
return false;
|
|
}
|
|
SelectedChannel selectedChannel = (SelectedChannel) obj;
|
|
return this.channelId == selectedChannel.channelId && m.areEqual(this.peekParent, selectedChannel.peekParent) && m.areEqual(this.analyticsLocation, selectedChannel.analyticsLocation);
|
|
}
|
|
|
|
public final SelectedChannelAnalyticsLocation getAnalyticsLocation() {
|
|
return this.analyticsLocation;
|
|
}
|
|
|
|
public final long getChannelId() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final Long getPeekParent() {
|
|
return this.peekParent;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int a = b.a(this.channelId) * 31;
|
|
Long l = this.peekParent;
|
|
int i = 0;
|
|
int hashCode = (a + (l != null ? l.hashCode() : 0)) * 31;
|
|
SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation = this.analyticsLocation;
|
|
if (selectedChannelAnalyticsLocation != null) {
|
|
i = selectedChannelAnalyticsLocation.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("SelectedChannel(channelId=");
|
|
K.append(this.channelId);
|
|
K.append(", peekParent=");
|
|
K.append(this.peekParent);
|
|
K.append(", analyticsLocation=");
|
|
K.append(this.analyticsLocation);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class ThreadDraft extends UserChannelSelection {
|
|
private final long parentChannelId;
|
|
private final Long starterMessageId;
|
|
|
|
public ThreadDraft(long j, Long l) {
|
|
super(null);
|
|
this.parentChannelId = j;
|
|
this.starterMessageId = l;
|
|
}
|
|
|
|
public static /* synthetic */ ThreadDraft copy$default(ThreadDraft threadDraft, long j, Long l, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = threadDraft.parentChannelId;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
l = threadDraft.starterMessageId;
|
|
}
|
|
return threadDraft.copy(j, l);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.parentChannelId;
|
|
}
|
|
|
|
public final Long component2() {
|
|
return this.starterMessageId;
|
|
}
|
|
|
|
public final ThreadDraft copy(long j, Long l) {
|
|
return new ThreadDraft(j, l);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ThreadDraft)) {
|
|
return false;
|
|
}
|
|
ThreadDraft threadDraft = (ThreadDraft) obj;
|
|
return this.parentChannelId == threadDraft.parentChannelId && m.areEqual(this.starterMessageId, threadDraft.starterMessageId);
|
|
}
|
|
|
|
public final long getParentChannelId() {
|
|
return this.parentChannelId;
|
|
}
|
|
|
|
public final Long getStarterMessageId() {
|
|
return this.starterMessageId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int a = b.a(this.parentChannelId) * 31;
|
|
Long l = this.starterMessageId;
|
|
return a + (l != null ? l.hashCode() : 0);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ThreadDraft(parentChannelId=");
|
|
K.append(this.parentChannelId);
|
|
K.append(", starterMessageId=");
|
|
return a.A(K, this.starterMessageId, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelsSelected.kt */
|
|
public static final class Unselected extends UserChannelSelection {
|
|
public static final Unselected INSTANCE = new Unselected();
|
|
|
|
private Unselected() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
private UserChannelSelection() {
|
|
}
|
|
|
|
public /* synthetic */ UserChannelSelection(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final long getId() {
|
|
if (this instanceof SelectedChannel) {
|
|
return ((SelectedChannel) this).getChannelId();
|
|
}
|
|
if (this instanceof ThreadDraft) {
|
|
return ((ThreadDraft) this).getParentChannelId();
|
|
}
|
|
if (m.areEqual(this, Unselected.INSTANCE)) {
|
|
return 0;
|
|
}
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
|
|
public final ResolvedSelectedChannel resolveWithChannel(Channel channel) {
|
|
ResolvedSelectedChannel threadDraft;
|
|
m.checkNotNullParameter(channel, "channel");
|
|
if (this instanceof Unselected) {
|
|
return ResolvedSelectedChannel.Unselected.INSTANCE;
|
|
}
|
|
if (this instanceof SelectedChannel) {
|
|
SelectedChannel selectedChannel = (SelectedChannel) this;
|
|
threadDraft = new ResolvedSelectedChannel.Channel(channel, selectedChannel.getPeekParent(), selectedChannel.getAnalyticsLocation());
|
|
} else if (this instanceof ThreadDraft) {
|
|
threadDraft = new ResolvedSelectedChannel.ThreadDraft(channel, ((ThreadDraft) this).getStarterMessageId());
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
return threadDraft;
|
|
}
|
|
}
|
|
|
|
public StoreChannelsSelected(StoreStream storeStream, StoreChannels storeChannels, StorePermissions storePermissions, StoreGuildSelected storeGuildSelected, Dispatcher dispatcher, ObservationDeck observationDeck) {
|
|
m.checkNotNullParameter(storeStream, "stream");
|
|
m.checkNotNullParameter(storeChannels, "storeChannels");
|
|
m.checkNotNullParameter(storePermissions, "storePermissions");
|
|
m.checkNotNullParameter(storeGuildSelected, "storeGuildSelected");
|
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
this.stream = storeStream;
|
|
this.storeChannels = storeChannels;
|
|
this.storePermissions = storePermissions;
|
|
this.storeGuildSelected = storeGuildSelected;
|
|
this.dispatcher = dispatcher;
|
|
this.observationDeck = observationDeck;
|
|
ResolvedSelectedChannel.Uninitialized uninitialized = ResolvedSelectedChannel.Uninitialized.INSTANCE;
|
|
this.selectedChannel = uninitialized;
|
|
this.previouslySelectedChannel = uninitialized;
|
|
Persister<ChannelFrecencyTracker> persister = new Persister<>("CHANNEL_HISTORY_V3", new ChannelFrecencyTracker());
|
|
this.frecencyCache = persister;
|
|
this.frecency = persister.get();
|
|
}
|
|
|
|
public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreChannelsSelected storeChannelsSelected) {
|
|
return storeChannelsSelected.dispatcher;
|
|
}
|
|
|
|
public static final /* synthetic */ boolean access$getInitializedForAuthedUser$p(StoreChannelsSelected storeChannelsSelected) {
|
|
return storeChannelsSelected.initializedForAuthedUser;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreChannelsSelected$Companion$InitializedUpdateSource$1 access$getInitializedUpdateSource$cp() {
|
|
return InitializedUpdateSource;
|
|
}
|
|
|
|
public static final /* synthetic */ ObservationDeck access$getObservationDeck$p(StoreChannelsSelected storeChannelsSelected) {
|
|
return storeChannelsSelected.observationDeck;
|
|
}
|
|
|
|
public static final /* synthetic */ ResolvedSelectedChannel access$getPreviouslySelectedChannel$p(StoreChannelsSelected storeChannelsSelected) {
|
|
return storeChannelsSelected.previouslySelectedChannel;
|
|
}
|
|
|
|
public static final /* synthetic */ ResolvedSelectedChannel access$getSelectedChannel$p(StoreChannelsSelected storeChannelsSelected) {
|
|
return storeChannelsSelected.selectedChannel;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreChannels access$getStoreChannels$p(StoreChannelsSelected storeChannelsSelected) {
|
|
return storeChannelsSelected.storeChannels;
|
|
}
|
|
|
|
public static final /* synthetic */ Subscription access$getValidateSelectedChannelSubscription$p(StoreChannelsSelected storeChannelsSelected) {
|
|
return storeChannelsSelected.validateSelectedChannelSubscription;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onSelectedChannelResolved(StoreChannelsSelected storeChannelsSelected, ResolvedSelectedChannel resolvedSelectedChannel) {
|
|
storeChannelsSelected.onSelectedChannelResolved(resolvedSelectedChannel);
|
|
}
|
|
|
|
public static final /* synthetic */ ResolvedSelectedChannel access$resolveSelectedChannel(StoreChannelsSelected storeChannelsSelected, UserChannelSelection userChannelSelection, Channel channel, Map map, long j, Map map2, boolean z2) {
|
|
return storeChannelsSelected.resolveSelectedChannel(userChannelSelection, channel, map, j, map2, z2);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setInitializedForAuthedUser$p(StoreChannelsSelected storeChannelsSelected, boolean z2) {
|
|
storeChannelsSelected.initializedForAuthedUser = z2;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setPreviouslySelectedChannel$p(StoreChannelsSelected storeChannelsSelected, ResolvedSelectedChannel resolvedSelectedChannel) {
|
|
storeChannelsSelected.previouslySelectedChannel = resolvedSelectedChannel;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setSelectedChannel$p(StoreChannelsSelected storeChannelsSelected, ResolvedSelectedChannel resolvedSelectedChannel) {
|
|
storeChannelsSelected.selectedChannel = resolvedSelectedChannel;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setValidateSelectedChannelSubscription$p(StoreChannelsSelected storeChannelsSelected, Subscription subscription) {
|
|
storeChannelsSelected.validateSelectedChannelSubscription = subscription;
|
|
}
|
|
|
|
private final Channel getFirstAvailableChannel(Map<Long, Channel> map, long j, Map<Long, Long> map2) {
|
|
Collection<Channel> values = map.values();
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Object obj : values) {
|
|
Channel channel = (Channel) obj;
|
|
if (channel.f() == j && AnimatableValueParser.l1(channel) && PermissionUtils.hasAccess(channel, map2)) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
return (Channel) u.firstOrNull((List<? extends Object>) u.sortedWith(arrayList, AnimatableValueParser.K0(Channel.Companion)));
|
|
}
|
|
|
|
private final boolean isValidResolution(Channel channel, long j, Map<Long, Long> map) {
|
|
return channel.f() == j && AnimatableValueParser.z1(channel) && PermissionUtils.hasAccess(channel, map);
|
|
}
|
|
|
|
@StoreThread
|
|
private final void loadFromCache() {
|
|
Map<Long, UserChannelSelection> map = this.userChannelSelections;
|
|
Map<Long, Long> map2 = this.selectedChannelIdsCache.get();
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap(g0.mapCapacity(map2.size()));
|
|
Iterator<T> it = map2.entrySet().iterator();
|
|
while (it.hasNext()) {
|
|
Map.Entry entry = (Map.Entry) it.next();
|
|
linkedHashMap.put(entry.getKey(), new UserChannelSelection.SelectedChannel(((Number) entry.getValue()).longValue(), null, null, 6, null));
|
|
}
|
|
map.putAll(linkedHashMap);
|
|
}
|
|
|
|
@StoreThread
|
|
private final void onSelectedChannelResolved(ResolvedSelectedChannel resolvedSelectedChannel) {
|
|
this.previouslySelectedChannel = this.selectedChannel;
|
|
this.selectedChannel = resolvedSelectedChannel;
|
|
boolean z2 = resolvedSelectedChannel instanceof ResolvedSelectedChannel.Channel;
|
|
if (z2) {
|
|
ResolvedSelectedChannel.Channel channel = (ResolvedSelectedChannel.Channel) resolvedSelectedChannel;
|
|
this.userChannelSelections.put(Long.valueOf(channel.getChannel().f()), new UserChannelSelection.SelectedChannel(channel.getChannel().h(), channel.getPeekParent(), null, 4, null));
|
|
FrecencyTracker.track$default(this.frecency, Long.valueOf(channel.getChannel().h()), 0, 2, null);
|
|
}
|
|
if (z2) {
|
|
ResolvedSelectedChannel.Channel channel2 = (ResolvedSelectedChannel.Channel) resolvedSelectedChannel;
|
|
this.stream.getAnalytics$app_productionBetaRelease().trackChannelOpened(resolvedSelectedChannel.getId(), channel2.getAnalyticsViewType(), channel2.getAnalyticsLocation());
|
|
}
|
|
updateInitializationState();
|
|
markChanged();
|
|
}
|
|
|
|
private final ResolvedSelectedChannel resolveSelectedChannel(UserChannelSelection userChannelSelection, Channel channel, Map<Long, Channel> map, long j, Map<Long, Long> map2, boolean z2) {
|
|
ResolvedSelectedChannel resolveWithChannel;
|
|
if (!z2) {
|
|
return ResolvedSelectedChannel.Uninitialized.INSTANCE;
|
|
}
|
|
if (channel != null && isValidResolution(channel, j, map2)) {
|
|
return (userChannelSelection == null || (resolveWithChannel = userChannelSelection.resolveWithChannel(channel)) == null) ? ResolvedSelectedChannel.Unselected.INSTANCE : resolveWithChannel;
|
|
}
|
|
if (j == 0) {
|
|
return ResolvedSelectedChannel.Unselected.INSTANCE;
|
|
}
|
|
Channel firstAvailableChannel = getFirstAvailableChannel(map, j, map2);
|
|
return firstAvailableChannel == null ? ResolvedSelectedChannel.Unavailable.INSTANCE : new ResolvedSelectedChannel.Channel(firstAvailableChannel, null, null);
|
|
}
|
|
|
|
@StoreThread
|
|
private final void updateInitializationState() {
|
|
boolean z2 = this.stream.getAuthentication$app_productionBetaRelease().getAuthToken$app_productionBetaRelease() != null;
|
|
boolean z3 = this.initializedForAuthedUser;
|
|
boolean z4 = z2 && this.storeChannels.getInitializedForAuthedUser$app_productionBetaRelease() && ((this.userChannelSelections.isEmpty() ^ true) || this.handledReadyPayload || this.isStoreInitTimedOut) && (m.areEqual(this.selectedChannel, ResolvedSelectedChannel.Uninitialized.INSTANCE) ^ true);
|
|
if (!z3 && z4) {
|
|
this.initializedForAuthedUser = true;
|
|
markChanged(InitializedUpdateSource);
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
private final void validateSelectedChannel() {
|
|
Subscription subscription = this.validateSelectedChannelSubscription;
|
|
if (subscription != null) {
|
|
subscription.unsubscribe();
|
|
}
|
|
Map<Long, Channel> channelsByIdInternal$app_productionBetaRelease = this.storeChannels.getChannelsByIdInternal$app_productionBetaRelease();
|
|
boolean initializedForAuthedUser$app_productionBetaRelease = this.storeChannels.getInitializedForAuthedUser$app_productionBetaRelease();
|
|
long selectedGuildIdInternal$app_productionBetaRelease = this.storeGuildSelected.getSelectedGuildIdInternal$app_productionBetaRelease();
|
|
Observable r = ObservableExtensionsKt.computationLatest(ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this.storeGuildSelected, this.storeChannels, this.storePermissions}, false, null, null, new StoreChannelsSelected$validateSelectedChannel$1(this, this.userChannelSelections.get(Long.valueOf(selectedGuildIdInternal$app_productionBetaRelease)), channelsByIdInternal$app_productionBetaRelease, selectedGuildIdInternal$app_productionBetaRelease, this.storePermissions.getPermissionsByChannelInternal$app_productionBetaRelease(selectedGuildIdInternal$app_productionBetaRelease), initializedForAuthedUser$app_productionBetaRelease), 14, null)).r();
|
|
m.checkNotNullExpressionValue(r, "observationDeck\n … .distinctUntilChanged()");
|
|
ObservableExtensionsKt.appSubscribe$default(r, StoreChannelsSelected.class, (Context) null, new StoreChannelsSelected$validateSelectedChannel$2(this), (Function1) null, (Function0) null, (Function0) null, new StoreChannelsSelected$validateSelectedChannel$3(this), 58, (Object) null);
|
|
}
|
|
|
|
@StoreThread
|
|
public final void dismissCreateThread() {
|
|
ResolvedSelectedChannel resolvedSelectedChannel = this.selectedChannel;
|
|
if (!(resolvedSelectedChannel instanceof ResolvedSelectedChannel.ThreadDraft)) {
|
|
resolvedSelectedChannel = null;
|
|
}
|
|
ResolvedSelectedChannel.ThreadDraft threadDraft = (ResolvedSelectedChannel.ThreadDraft) resolvedSelectedChannel;
|
|
if (threadDraft != null) {
|
|
Channel parentChannel = threadDraft.getParentChannel();
|
|
this.userChannelSelections.put(Long.valueOf(parentChannel.f()), new UserChannelSelection.SelectedChannel(parentChannel.h(), null, null, 6, null));
|
|
validateSelectedChannel();
|
|
}
|
|
}
|
|
|
|
public final ChannelFrecencyTracker getFrecency() {
|
|
return this.frecency;
|
|
}
|
|
|
|
public final long getId() {
|
|
return this.selectedChannel.getId();
|
|
}
|
|
|
|
public final Channel getSelectedChannel() {
|
|
ResolvedSelectedChannel resolvedSelectedChannel = this.selectedChannel;
|
|
if (!(resolvedSelectedChannel instanceof ResolvedSelectedChannel.Channel)) {
|
|
resolvedSelectedChannel = null;
|
|
}
|
|
ResolvedSelectedChannel.Channel channel = (ResolvedSelectedChannel.Channel) resolvedSelectedChannel;
|
|
if (channel != null) {
|
|
return channel.getChannel();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleChannelOrThreadCreateOrUpdate(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
if (channel.h() == this.selectedChannel.getId()) {
|
|
validateSelectedChannel();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleChannelOrThreadDelete(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
if (channel.h() == this.selectedChannel.getId()) {
|
|
validateSelectedChannel();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleConnectionOpen(ModelPayload modelPayload) {
|
|
m.checkNotNullParameter(modelPayload, "payload");
|
|
List<Guild> guilds = modelPayload.getGuilds();
|
|
m.checkNotNullExpressionValue(guilds, "payload.guilds");
|
|
HashSet hashSetOf = n0.hashSetOf(0L);
|
|
for (Guild guild : guilds) {
|
|
hashSetOf.add(Long.valueOf(guild.o()));
|
|
}
|
|
Map<Long, UserChannelSelection> map = this.userChannelSelections;
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
for (Map.Entry<Long, UserChannelSelection> entry : map.entrySet()) {
|
|
if (hashSetOf.contains(Long.valueOf(entry.getKey().longValue()))) {
|
|
linkedHashMap.put(entry.getKey(), entry.getValue());
|
|
}
|
|
}
|
|
Map<? extends Long, ? extends UserChannelSelection> mutableMap = h0.toMutableMap(linkedHashMap);
|
|
if (!mutableMap.containsKey(0L)) {
|
|
mutableMap.put(0L, UserChannelSelection.Unselected.INSTANCE);
|
|
}
|
|
this.userChannelSelections.clear();
|
|
this.userChannelSelections.putAll(mutableMap);
|
|
this.handledReadyPayload = true;
|
|
validateSelectedChannel();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildAdd(Guild guild) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
if (this.storeGuildSelected.getSelectedGuildIdInternal$app_productionBetaRelease() == guild.o()) {
|
|
validateSelectedChannel();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildSelected() {
|
|
validateSelectedChannel();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleStoreInitTimeout() {
|
|
this.isStoreInitTimedOut = true;
|
|
updateInitializationState();
|
|
if (m.areEqual(this.selectedChannel, ResolvedSelectedChannel.Uninitialized.INSTANCE)) {
|
|
validateSelectedChannel();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void init() {
|
|
loadFromCache();
|
|
validateSelectedChannel();
|
|
}
|
|
|
|
public final Observable<Long> observeId() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannelsSelected$observeId$1(this), 14, null);
|
|
}
|
|
|
|
public final Observable<Boolean> observeInitializedForAuthedUser() {
|
|
Observable<R> Y = this.storeChannels.observeInitializedForAuthedUser().Y(new StoreChannelsSelected$observeInitializedForAuthedUser$1(this));
|
|
m.checkNotNullExpressionValue(Y, "storeChannels.observeIni… }\n }");
|
|
return Y;
|
|
}
|
|
|
|
public final Observable<Long> observePreviousId() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannelsSelected$observePreviousId$1(this), 14, null);
|
|
}
|
|
|
|
public final Observable<ResolvedSelectedChannel> observeResolvedSelectedChannel() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannelsSelected$observeResolvedSelectedChannel$1(this), 14, null);
|
|
}
|
|
|
|
public final Observable<Channel> observeSelectedChannel() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannelsSelected$observeSelectedChannel$1(this), 14, null);
|
|
}
|
|
|
|
@StoreThread
|
|
public final void openCreateThread(long j, long j2, Long l) {
|
|
this.userChannelSelections.put(Long.valueOf(j), new UserChannelSelection.ThreadDraft(j2, l));
|
|
validateSelectedChannel();
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
@StoreThread
|
|
public void snapshotData() {
|
|
Persister.set$default(this.frecencyCache, this.frecency, false, 2, null);
|
|
Map<Long, UserChannelSelection> map = this.userChannelSelections;
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap(g0.mapCapacity(map.size()));
|
|
Iterator<T> it = map.entrySet().iterator();
|
|
while (it.hasNext()) {
|
|
Map.Entry entry = (Map.Entry) it.next();
|
|
linkedHashMap.put(entry.getKey(), Long.valueOf(((UserChannelSelection) entry.getValue()).getId()));
|
|
}
|
|
this.selectedChannelIdsCache.set(linkedHashMap, true);
|
|
}
|
|
|
|
@StoreThread
|
|
public final void trySelectChannel(long j, long j2, Long l, SelectedChannelAnalyticsLocation selectedChannelAnalyticsLocation) {
|
|
UserChannelSelection userChannelSelection = this.userChannelSelections.get(Long.valueOf(j));
|
|
if (!(userChannelSelection instanceof UserChannelSelection.SelectedChannel)) {
|
|
userChannelSelection = null;
|
|
}
|
|
UserChannelSelection.SelectedChannel selectedChannel = (UserChannelSelection.SelectedChannel) userChannelSelection;
|
|
if (selectedChannel == null || selectedChannel.getChannelId() != j2) {
|
|
this.userChannelSelections.put(Long.valueOf(j), new UserChannelSelection.SelectedChannel(j2, l, selectedChannelAnalyticsLocation));
|
|
validateSelectedChannel();
|
|
}
|
|
}
|
|
}
|