318 lines
12 KiB
Java
318 lines
12 KiB
Java
package com.discord.stores;
|
|
|
|
import a0.a.a.b;
|
|
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.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.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 {
|
|
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 JoinedThread {
|
|
private final int flags;
|
|
private final long guildId;
|
|
private final UtcDateTime joinTimestamp;
|
|
private final long threadId;
|
|
|
|
public JoinedThread(long j, long j2, int i, UtcDateTime utcDateTime) {
|
|
m.checkNotNullParameter(utcDateTime, "joinTimestamp");
|
|
this.threadId = j;
|
|
this.guildId = j2;
|
|
this.flags = i;
|
|
this.joinTimestamp = utcDateTime;
|
|
}
|
|
|
|
public static /* synthetic */ JoinedThread copy$default(JoinedThread joinedThread, long j, long j2, int i, UtcDateTime utcDateTime, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
j = joinedThread.threadId;
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
j2 = joinedThread.guildId;
|
|
}
|
|
if ((i2 & 4) != 0) {
|
|
i = joinedThread.flags;
|
|
}
|
|
if ((i2 & 8) != 0) {
|
|
utcDateTime = joinedThread.joinTimestamp;
|
|
}
|
|
return joinedThread.copy(j, j2, i, utcDateTime);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.threadId;
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final int component3() {
|
|
return this.flags;
|
|
}
|
|
|
|
public final UtcDateTime component4() {
|
|
return this.joinTimestamp;
|
|
}
|
|
|
|
public final JoinedThread copy(long j, long j2, int i, UtcDateTime utcDateTime) {
|
|
m.checkNotNullParameter(utcDateTime, "joinTimestamp");
|
|
return new JoinedThread(j, j2, i, 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 && 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 long getThreadId() {
|
|
return this.threadId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int a = (((b.a(this.guildId) + (b.a(this.threadId) * 31)) * 31) + this.flags) * 31;
|
|
UtcDateTime utcDateTime = this.joinTimestamp;
|
|
return a + (utcDateTime != null ? utcDateTime.hashCode() : 0);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("JoinedThread(threadId=");
|
|
L.append(this.threadId);
|
|
L.append(", guildId=");
|
|
L.append(this.guildId);
|
|
L.append(", flags=");
|
|
L.append(this.flags);
|
|
L.append(", joinTimestamp=");
|
|
L.append(this.joinTimestamp);
|
|
L.append(")");
|
|
return L.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);
|
|
}
|
|
|
|
private final void deleteThreads(long j) {
|
|
if (r.removeAll(this.joinedThreads.values(), new StoreThreadsJoined$deleteThreads$removed$1(j))) {
|
|
markChanged();
|
|
}
|
|
}
|
|
|
|
private final void saveThreads(Guild guild) {
|
|
ThreadMember j;
|
|
List<Channel> K = guild.K();
|
|
if (K != null) {
|
|
for (Channel channel : K) {
|
|
if (AnimatableValueParser.z1(channel) && (j = channel.j()) != null) {
|
|
this.joinedThreads.put(Long.valueOf(channel.h()), new JoinedThread(channel.h(), guild.o(), j.a(), j.c()));
|
|
markChanged();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final Map<Long, JoinedThread> getAllJoinedThreadsInternal$app_productionBetaRelease() {
|
|
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.o());
|
|
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.d() == this.storeUser.getMe().getId()) {
|
|
this.joinedThreads.put(Long.valueOf(threadMember.b()), new JoinedThread(threadMember.b(), f, threadMember.a(), threadMember.c()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleThreadCreateOrUpdate(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
ThreadMember j = channel.j();
|
|
if (j != null && j.d() == this.storeUser.getMe().getId()) {
|
|
this.joinedThreads.put(Long.valueOf(channel.h()), new JoinedThread(channel.h(), channel.f(), j.a(), 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.c()));
|
|
markChanged();
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleThreadMemberUpdate(ThreadMemberUpdate threadMemberUpdate) {
|
|
m.checkNotNullParameter(threadMemberUpdate, "payload");
|
|
if (threadMemberUpdate.e() == this.storeUser.getMe().getId()) {
|
|
this.joinedThreads.put(Long.valueOf(threadMemberUpdate.c()), new JoinedThread(threadMemberUpdate.c(), threadMemberUpdate.b(), threadMemberUpdate.a(), 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).e() == 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.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);
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
@StoreThread
|
|
public void snapshotData() {
|
|
this.joinedThreadsSnapshot = new HashMap(this.joinedThreads);
|
|
}
|
|
}
|