discord-jadx/app/src/main/java/com/discord/stores/StoreThreadsJoined.java

372 lines
14 KiB
Java

package com.discord.stores;
import a0.a.a.b;
import c.d.b.a.a;
import com.discord.api.channel.Channel;
import com.discord.api.channel.ChannelUtils;
import com.discord.api.guild.Guild;
import com.discord.api.thread.AugmentedThreadMember;
import com.discord.api.thread.ThreadMember;
import com.discord.api.thread.ThreadMemberUpdate;
import com.discord.api.thread.ThreadMembersUpdate;
import com.discord.api.utcdatetime.UtcDateTime;
import com.discord.models.domain.ModelMuteConfig;
import com.discord.models.domain.ModelPayload;
import com.discord.models.thread.dto.ModelThreadListSync;
import com.discord.stores.updates.ObservationDeck;
import com.discord.stores.updates.ObservationDeckProvider;
import com.discord.utilities.search.network.state.SearchState;
import d0.t.h0;
import d0.t.r;
import d0.z.d.m;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
/* compiled from: StoreThreadsJoined.kt */
public final class StoreThreadsJoined extends StoreV2 {
public static final int ALL_FLAGS = 15;
public static final Companion Companion = new Companion(null);
public static final int NOTIFICATION_FLAGS = 14;
private final Map<Long, JoinedThread> joinedThreads;
private Map<Long, JoinedThread> joinedThreadsSnapshot;
private final ObservationDeck observationDeck;
private final StoreUser storeUser;
/* compiled from: StoreThreadsJoined.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: StoreThreadsJoined.kt */
public static final class JoinedThread {
private final int flags;
private final long guildId;
private final UtcDateTime joinTimestamp;
private final ModelMuteConfig muteConfig;
private final boolean muted;
private final long threadId;
public JoinedThread(long j, long j2, int i, boolean z2, ModelMuteConfig modelMuteConfig, UtcDateTime utcDateTime) {
m.checkNotNullParameter(modelMuteConfig, "muteConfig");
m.checkNotNullParameter(utcDateTime, "joinTimestamp");
this.threadId = j;
this.guildId = j2;
this.flags = i;
this.muted = z2;
this.muteConfig = modelMuteConfig;
this.joinTimestamp = utcDateTime;
}
public static /* synthetic */ JoinedThread copy$default(JoinedThread joinedThread, long j, long j2, int i, boolean z2, ModelMuteConfig modelMuteConfig, UtcDateTime utcDateTime, int i2, Object obj) {
return joinedThread.copy((i2 & 1) != 0 ? joinedThread.threadId : j, (i2 & 2) != 0 ? joinedThread.guildId : j2, (i2 & 4) != 0 ? joinedThread.flags : i, (i2 & 8) != 0 ? joinedThread.muted : z2, (i2 & 16) != 0 ? joinedThread.muteConfig : modelMuteConfig, (i2 & 32) != 0 ? joinedThread.joinTimestamp : utcDateTime);
}
public final long component1() {
return this.threadId;
}
public final long component2() {
return this.guildId;
}
public final int component3() {
return this.flags;
}
public final boolean component4() {
return this.muted;
}
public final ModelMuteConfig component5() {
return this.muteConfig;
}
public final UtcDateTime component6() {
return this.joinTimestamp;
}
public final JoinedThread copy(long j, long j2, int i, boolean z2, ModelMuteConfig modelMuteConfig, UtcDateTime utcDateTime) {
m.checkNotNullParameter(modelMuteConfig, "muteConfig");
m.checkNotNullParameter(utcDateTime, "joinTimestamp");
return new JoinedThread(j, j2, i, z2, modelMuteConfig, utcDateTime);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof JoinedThread)) {
return false;
}
JoinedThread joinedThread = (JoinedThread) obj;
return this.threadId == joinedThread.threadId && this.guildId == joinedThread.guildId && this.flags == joinedThread.flags && this.muted == joinedThread.muted && m.areEqual(this.muteConfig, joinedThread.muteConfig) && m.areEqual(this.joinTimestamp, joinedThread.joinTimestamp);
}
public final int getFlags() {
return this.flags;
}
public final long getGuildId() {
return this.guildId;
}
public final UtcDateTime getJoinTimestamp() {
return this.joinTimestamp;
}
public final ModelMuteConfig getMuteConfig() {
return this.muteConfig;
}
public final boolean getMuted() {
return this.muted;
}
public final long getThreadId() {
return this.threadId;
}
public int hashCode() {
int a = (((b.a(this.guildId) + (b.a(this.threadId) * 31)) * 31) + this.flags) * 31;
boolean z2 = this.muted;
if (z2) {
z2 = true;
}
int i = z2 ? 1 : 0;
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = (a + i) * 31;
ModelMuteConfig modelMuteConfig = this.muteConfig;
int i5 = 0;
int hashCode = (i4 + (modelMuteConfig != null ? modelMuteConfig.hashCode() : 0)) * 31;
UtcDateTime utcDateTime = this.joinTimestamp;
if (utcDateTime != null) {
i5 = utcDateTime.hashCode();
}
return hashCode + i5;
}
public String toString() {
StringBuilder R = a.R("JoinedThread(threadId=");
R.append(this.threadId);
R.append(", guildId=");
R.append(this.guildId);
R.append(", flags=");
R.append(this.flags);
R.append(", muted=");
R.append(this.muted);
R.append(", muteConfig=");
R.append(this.muteConfig);
R.append(", joinTimestamp=");
R.append(this.joinTimestamp);
R.append(")");
return R.toString();
}
}
public StoreThreadsJoined(StoreUser storeUser, ObservationDeck observationDeck) {
m.checkNotNullParameter(storeUser, "storeUser");
m.checkNotNullParameter(observationDeck, "observationDeck");
this.storeUser = storeUser;
this.observationDeck = observationDeck;
this.joinedThreads = new HashMap();
this.joinedThreadsSnapshot = h0.emptyMap();
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ StoreThreadsJoined(StoreUser storeUser, ObservationDeck observationDeck, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(storeUser, (i & 2) != 0 ? ObservationDeckProvider.get() : observationDeck);
}
public static final /* synthetic */ Map access$getAllJoinedThreads(StoreThreadsJoined storeThreadsJoined) {
return storeThreadsJoined.getAllJoinedThreads();
}
private final void deleteThreads(long j) {
if (r.removeAll(this.joinedThreads.values(), new StoreThreadsJoined$deleteThreads$removed$1(j))) {
markChanged();
}
}
private final Map<Long, JoinedThread> getAllJoinedThreads() {
return this.joinedThreadsSnapshot;
}
private final void saveThreads(Guild guild) {
ThreadMember j;
List<Channel> N = guild.N();
if (N != null) {
for (Channel channel : N) {
if (ChannelUtils.C(channel) && (j = channel.j()) != null) {
this.joinedThreads.put(Long.valueOf(channel.h()), new JoinedThread(channel.h(), guild.r(), j.a(), j.e(), new ModelMuteConfig(j.d()), j.c()));
markChanged();
}
}
}
}
@StoreThread
public final Map<Long, JoinedThread> getAllJoinedThreadsInternal$app_productionCanaryRelease() {
return this.joinedThreads;
}
public final JoinedThread getJoinedThread(long j) {
return this.joinedThreadsSnapshot.get(Long.valueOf(j));
}
@StoreThread
public final void handleConnectionOpen(ModelPayload modelPayload) {
m.checkNotNullParameter(modelPayload, "payload");
this.joinedThreads.clear();
List<Guild> guilds = modelPayload.getGuilds();
m.checkNotNullExpressionValue(guilds, "payload.guilds");
for (Guild guild : guilds) {
m.checkNotNullExpressionValue(guild, "guild");
saveThreads(guild);
}
markChanged();
}
@StoreThread
public final void handleGuildCreate(Guild guild) {
m.checkNotNullParameter(guild, "guild");
deleteThreads(guild.r());
saveThreads(guild);
}
@StoreThread
public final void handleGuildDelete(long j) {
deleteThreads(j);
}
@StoreThread
public final void handleSearchFinish(SearchState searchState) {
Channel channel;
m.checkNotNullParameter(searchState, "searchState");
List<Channel> threads = searchState.getThreads();
if (!(threads == null || (channel = threads.get(0)) == null)) {
long f = channel.f();
List<ThreadMember> threadMembers = searchState.getThreadMembers();
if (threadMembers != null) {
for (ThreadMember threadMember : threadMembers) {
if (threadMember.f() == this.storeUser.getMe().getId()) {
this.joinedThreads.put(Long.valueOf(threadMember.b()), new JoinedThread(threadMember.b(), f, threadMember.a(), threadMember.e(), new ModelMuteConfig(threadMember.d()), threadMember.c()));
}
}
}
}
}
@StoreThread
public final void handleThreadCreateOrUpdate(Channel channel) {
m.checkNotNullParameter(channel, "channel");
ThreadMember j = channel.j();
if (j != null && j.f() == this.storeUser.getMe().getId()) {
this.joinedThreads.put(Long.valueOf(channel.h()), new JoinedThread(channel.h(), channel.f(), j.a(), j.e(), new ModelMuteConfig(j.d()), j.c()));
markChanged();
}
}
@StoreThread
public final void handleThreadDelete(Channel channel) {
m.checkNotNullParameter(channel, "channel");
if (this.joinedThreads.containsKey(Long.valueOf(channel.h()))) {
this.joinedThreads.remove(Long.valueOf(channel.h()));
markChanged();
}
}
@StoreThread
public final void handleThreadListSync(ModelThreadListSync modelThreadListSync) {
m.checkNotNullParameter(modelThreadListSync, "payload");
List<ThreadMember> members = modelThreadListSync.getMembers();
if (members != null) {
for (ThreadMember threadMember : members) {
this.joinedThreads.put(Long.valueOf(threadMember.b()), new JoinedThread(threadMember.b(), modelThreadListSync.getGuildId(), threadMember.a(), threadMember.e(), new ModelMuteConfig(threadMember.d()), threadMember.c()));
markChanged();
}
}
}
@StoreThread
public final void handleThreadMemberUpdate(ThreadMemberUpdate threadMemberUpdate) {
m.checkNotNullParameter(threadMemberUpdate, "payload");
if (threadMemberUpdate.g() == this.storeUser.getMe().getId()) {
this.joinedThreads.put(Long.valueOf(threadMemberUpdate.c()), new JoinedThread(threadMemberUpdate.c(), threadMemberUpdate.b(), threadMemberUpdate.a(), threadMemberUpdate.f(), new ModelMuteConfig(threadMemberUpdate.e()), threadMemberUpdate.d()));
markChanged();
}
}
/* JADX DEBUG: Multi-variable search result rejected for r5v2, resolved type: java.lang.Object */
/* JADX WARN: Multi-variable type inference failed */
@StoreThread
public final void handleThreadMembersUpdate(ThreadMembersUpdate threadMembersUpdate) {
boolean z2;
List<Long> d;
m.checkNotNullParameter(threadMembersUpdate, "payload");
long id2 = this.storeUser.getMe().getId();
if (this.joinedThreads.containsKey(Long.valueOf(threadMembersUpdate.c())) && (d = threadMembersUpdate.d()) != null && d.contains(Long.valueOf(id2))) {
this.joinedThreads.remove(Long.valueOf(threadMembersUpdate.c()));
markChanged();
}
List<AugmentedThreadMember> a = threadMembersUpdate.a();
AugmentedThreadMember augmentedThreadMember = null;
if (a != null) {
Iterator<T> it = a.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Object next = it.next();
if (((AugmentedThreadMember) next).g() == id2) {
z2 = true;
continue;
} else {
z2 = false;
continue;
}
if (z2) {
augmentedThreadMember = next;
break;
}
}
augmentedThreadMember = augmentedThreadMember;
}
if (augmentedThreadMember != null) {
this.joinedThreads.put(Long.valueOf(threadMembersUpdate.c()), new JoinedThread(threadMembersUpdate.c(), threadMembersUpdate.b(), augmentedThreadMember.a(), augmentedThreadMember.e(), new ModelMuteConfig(augmentedThreadMember.d()), augmentedThreadMember.b()));
markChanged();
}
}
public final boolean hasJoined(long j) {
return this.joinedThreadsSnapshot.containsKey(Long.valueOf(j));
}
@StoreThread
public final boolean hasJoinedInternal(long j) {
return this.joinedThreads.containsKey(Long.valueOf(j));
}
public final Observable<JoinedThread> observeJoinedThread(long j) {
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreThreadsJoined$observeJoinedThread$1(this, j), 14, null);
}
public final Observable<Map<Long, JoinedThread>> observeJoinedThreads() {
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreThreadsJoined$observeJoinedThreads$1(this), 14, null);
}
@Override // com.discord.stores.StoreV2
@StoreThread
public void snapshotData() {
this.joinedThreadsSnapshot = new HashMap(this.joinedThreads);
}
}