316 lines
14 KiB
Java
316 lines
14 KiB
Java
package com.discord.stores;
|
|
|
|
import c.d.b.a.a;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.guild.Guild;
|
|
import com.discord.api.thread.ThreadMemberUpdate;
|
|
import com.discord.api.thread.ThreadMembersUpdate;
|
|
import com.discord.api.utcdatetime.UtcDateTime;
|
|
import com.discord.models.thread.dto.ModelThreadListSync;
|
|
import com.discord.stores.StoreThreadsJoined;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
import d0.t.g0;
|
|
import d0.t.o;
|
|
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 kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: StoreThreadsActiveJoined.kt */
|
|
public final class StoreThreadsActiveJoined extends StoreV2 {
|
|
private final Map<Long, ActiveJoinedThread> activeJoinedThreads;
|
|
private Map<Long, ActiveJoinedThread> activeJoinedThreadsByThreadIdSnapshot;
|
|
private Map<Long, ? extends Map<Long, ? extends Map<Long, ActiveJoinedThread>>> activeJoinedThreadsHierarchicalSnapshot;
|
|
private final ObservationDeck observationDeck;
|
|
private final StoreThreadsActive storeThreadsActive;
|
|
private final StoreThreadsJoined storeThreadsJoined;
|
|
|
|
/* compiled from: StoreThreadsActiveJoined.kt */
|
|
public static final class ActiveJoinedThread {
|
|
private final Channel channel;
|
|
private final UtcDateTime joinTimestamp;
|
|
|
|
public ActiveJoinedThread(Channel channel, UtcDateTime utcDateTime) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(utcDateTime, "joinTimestamp");
|
|
this.channel = channel;
|
|
this.joinTimestamp = utcDateTime;
|
|
}
|
|
|
|
public static /* synthetic */ ActiveJoinedThread copy$default(ActiveJoinedThread activeJoinedThread, Channel channel, UtcDateTime utcDateTime, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
channel = activeJoinedThread.channel;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
utcDateTime = activeJoinedThread.joinTimestamp;
|
|
}
|
|
return activeJoinedThread.copy(channel, utcDateTime);
|
|
}
|
|
|
|
public final Channel component1() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final UtcDateTime component2() {
|
|
return this.joinTimestamp;
|
|
}
|
|
|
|
public final ActiveJoinedThread copy(Channel channel, UtcDateTime utcDateTime) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(utcDateTime, "joinTimestamp");
|
|
return new ActiveJoinedThread(channel, utcDateTime);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ActiveJoinedThread)) {
|
|
return false;
|
|
}
|
|
ActiveJoinedThread activeJoinedThread = (ActiveJoinedThread) obj;
|
|
return m.areEqual(this.channel, activeJoinedThread.channel) && m.areEqual(this.joinTimestamp, activeJoinedThread.joinTimestamp);
|
|
}
|
|
|
|
public final Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final UtcDateTime getJoinTimestamp() {
|
|
return this.joinTimestamp;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Channel channel = this.channel;
|
|
int i = 0;
|
|
int hashCode = (channel != null ? channel.hashCode() : 0) * 31;
|
|
UtcDateTime utcDateTime = this.joinTimestamp;
|
|
if (utcDateTime != null) {
|
|
i = utcDateTime.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("ActiveJoinedThread(channel=");
|
|
L.append(this.channel);
|
|
L.append(", joinTimestamp=");
|
|
L.append(this.joinTimestamp);
|
|
L.append(")");
|
|
return L.toString();
|
|
}
|
|
}
|
|
|
|
public StoreThreadsActiveJoined(StoreThreadsActive storeThreadsActive, StoreThreadsJoined storeThreadsJoined, ObservationDeck observationDeck) {
|
|
m.checkNotNullParameter(storeThreadsActive, "storeThreadsActive");
|
|
m.checkNotNullParameter(storeThreadsJoined, "storeThreadsJoined");
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
this.storeThreadsActive = storeThreadsActive;
|
|
this.storeThreadsJoined = storeThreadsJoined;
|
|
this.observationDeck = observationDeck;
|
|
this.activeJoinedThreads = new HashMap();
|
|
this.activeJoinedThreadsByThreadIdSnapshot = new HashMap();
|
|
this.activeJoinedThreadsHierarchicalSnapshot = new HashMap();
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ StoreThreadsActiveJoined(StoreThreadsActive storeThreadsActive, StoreThreadsJoined storeThreadsJoined, ObservationDeck observationDeck, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(storeThreadsActive, storeThreadsJoined, (i & 4) != 0 ? ObservationDeckProvider.get() : observationDeck);
|
|
}
|
|
|
|
public static final /* synthetic */ Map access$getActiveJoinedThreadsByThreadIdSnapshot$p(StoreThreadsActiveJoined storeThreadsActiveJoined) {
|
|
return storeThreadsActiveJoined.activeJoinedThreadsByThreadIdSnapshot;
|
|
}
|
|
|
|
public static final /* synthetic */ Map access$getActiveJoinedThreadsHierarchicalSnapshot$p(StoreThreadsActiveJoined storeThreadsActiveJoined) {
|
|
return storeThreadsActiveJoined.activeJoinedThreadsHierarchicalSnapshot;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setActiveJoinedThreadsByThreadIdSnapshot$p(StoreThreadsActiveJoined storeThreadsActiveJoined, Map map) {
|
|
storeThreadsActiveJoined.activeJoinedThreadsByThreadIdSnapshot = map;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setActiveJoinedThreadsHierarchicalSnapshot$p(StoreThreadsActiveJoined storeThreadsActiveJoined, Map map) {
|
|
storeThreadsActiveJoined.activeJoinedThreadsHierarchicalSnapshot = map;
|
|
}
|
|
|
|
@StoreThread
|
|
private final void saveThreads(Long l) {
|
|
Channel channel;
|
|
Map<Long, Map<Long, Channel>> allActiveThreadsInternal$app_productionBetaRelease = this.storeThreadsActive.getAllActiveThreadsInternal$app_productionBetaRelease();
|
|
for (StoreThreadsJoined.JoinedThread joinedThread : this.storeThreadsJoined.getAllJoinedThreadsInternal$app_productionBetaRelease().values()) {
|
|
if (l == null || joinedThread.getGuildId() == l.longValue()) {
|
|
Map<Long, Channel> map = allActiveThreadsInternal$app_productionBetaRelease.get(Long.valueOf(joinedThread.getGuildId()));
|
|
if (!(map == null || (channel = map.get(Long.valueOf(joinedThread.getThreadId()))) == null)) {
|
|
this.activeJoinedThreads.put(Long.valueOf(channel.h()), new ActiveJoinedThread(channel, joinedThread.getJoinTimestamp()));
|
|
markChanged();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static /* synthetic */ void saveThreads$default(StoreThreadsActiveJoined storeThreadsActiveJoined, Long l, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
l = null;
|
|
}
|
|
storeThreadsActiveJoined.saveThreads(l);
|
|
}
|
|
|
|
@StoreThread
|
|
private final void updateThread(long j, long j2) {
|
|
Map<Long, Channel> map = this.storeThreadsActive.getAllActiveThreadsInternal$app_productionBetaRelease().get(Long.valueOf(j));
|
|
Channel channel = map != null ? map.get(Long.valueOf(j2)) : null;
|
|
StoreThreadsJoined.JoinedThread joinedThread = this.storeThreadsJoined.getAllJoinedThreadsInternal$app_productionBetaRelease().get(Long.valueOf(j2));
|
|
if (channel != null && joinedThread != null) {
|
|
this.activeJoinedThreads.put(Long.valueOf(j2), new ActiveJoinedThread(channel, joinedThread.getJoinTimestamp()));
|
|
markChanged();
|
|
} else if (this.activeJoinedThreads.containsKey(Long.valueOf(j2))) {
|
|
this.activeJoinedThreads.remove(Long.valueOf(j2));
|
|
markChanged();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final List<Channel> getActiveJoinedThreadsForChannelInternal$app_productionBetaRelease(long j) {
|
|
Collection<ActiveJoinedThread> values = this.activeJoinedThreads.values();
|
|
ArrayList<ActiveJoinedThread> arrayList = new ArrayList();
|
|
for (Object obj : values) {
|
|
if (((ActiveJoinedThread) obj).getChannel().r() == j) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
ArrayList arrayList2 = new ArrayList(o.collectionSizeOrDefault(arrayList, 10));
|
|
for (ActiveJoinedThread activeJoinedThread : arrayList) {
|
|
arrayList2.add(activeJoinedThread.getChannel());
|
|
}
|
|
return arrayList2;
|
|
}
|
|
|
|
@StoreThread
|
|
public final Map<Long, ActiveJoinedThread> getActiveJoinedThreadsInternal$app_productionBetaRelease() {
|
|
return this.activeJoinedThreads;
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleChannelCreateOrUpdate(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
for (Channel channel2 : getActiveJoinedThreadsForChannelInternal$app_productionBetaRelease(channel.h())) {
|
|
updateThread(channel2.f(), channel2.h());
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleConnectionOpen() {
|
|
this.activeJoinedThreads.clear();
|
|
saveThreads$default(this, null, 1, null);
|
|
markChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildCreate(Guild guild) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
saveThreads(Long.valueOf(guild.o()));
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildDelete(long j) {
|
|
Iterator<ActiveJoinedThread> it = this.activeJoinedThreads.values().iterator();
|
|
while (it.hasNext()) {
|
|
if (it.next().getChannel().f() == j) {
|
|
it.remove();
|
|
markChanged();
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleThreadCreateOrUpdateOrDelete(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
updateThread(channel.f(), channel.h());
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleThreadListSync(ModelThreadListSync modelThreadListSync) {
|
|
m.checkNotNullParameter(modelThreadListSync, "payload");
|
|
handleGuildDelete(modelThreadListSync.getGuildId());
|
|
saveThreads(Long.valueOf(modelThreadListSync.getGuildId()));
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleThreadMemberUpdate(ThreadMemberUpdate threadMemberUpdate) {
|
|
m.checkNotNullParameter(threadMemberUpdate, "payload");
|
|
updateThread(threadMemberUpdate.b(), threadMemberUpdate.c());
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleThreadMembersUpdate(ThreadMembersUpdate threadMembersUpdate) {
|
|
m.checkNotNullParameter(threadMembersUpdate, "payload");
|
|
updateThread(threadMembersUpdate.b(), threadMembersUpdate.c());
|
|
}
|
|
|
|
public final Observable<Map<Long, ActiveJoinedThread>> observeActiveJoinedThreadsForChannel(long j, long j2) {
|
|
Observable<Map<Long, ActiveJoinedThread>> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreThreadsActiveJoined$observeActiveJoinedThreadsForChannel$1(this, j, j2), 14, null).r();
|
|
m.checkNotNullExpressionValue(r, "observationDeck\n … .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
public final Observable<Map<Long, Map<Long, ActiveJoinedThread>>> observeActiveJoinedThreadsForGuild(long j) {
|
|
Observable<Map<Long, Map<Long, ActiveJoinedThread>>> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreThreadsActiveJoined$observeActiveJoinedThreadsForGuild$1(this, j), 14, null).r();
|
|
m.checkNotNullExpressionValue(r, "observationDeck\n … .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
public final Observable<Map<Long, ActiveJoinedThread>> observeAllActiveJoinedThreadsById() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreThreadsActiveJoined$observeAllActiveJoinedThreadsById$1(this), 14, null);
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
@StoreThread
|
|
public void snapshotData() {
|
|
this.activeJoinedThreadsByThreadIdSnapshot = new HashMap(this.activeJoinedThreads);
|
|
Collection<ActiveJoinedThread> values = this.activeJoinedThreads.values();
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
for (Object obj : values) {
|
|
Long valueOf = Long.valueOf(((ActiveJoinedThread) obj).getChannel().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();
|
|
LinkedHashMap linkedHashMap3 = new LinkedHashMap();
|
|
for (Object obj3 : (List) entry.getValue()) {
|
|
Long valueOf2 = Long.valueOf(((ActiveJoinedThread) obj3).getChannel().r());
|
|
Object obj4 = linkedHashMap3.get(valueOf2);
|
|
if (obj4 == null) {
|
|
obj4 = new ArrayList();
|
|
linkedHashMap3.put(valueOf2, obj4);
|
|
}
|
|
((List) obj4).add(obj3);
|
|
}
|
|
LinkedHashMap linkedHashMap4 = new LinkedHashMap(g0.mapCapacity(linkedHashMap3.size()));
|
|
for (Map.Entry entry2 : linkedHashMap3.entrySet()) {
|
|
Object key2 = entry2.getKey();
|
|
List list = (List) entry2.getValue();
|
|
LinkedHashMap linkedHashMap5 = new LinkedHashMap(a.I(list, 10, 16));
|
|
for (Object obj5 : list) {
|
|
linkedHashMap5.put(Long.valueOf(((ActiveJoinedThread) obj5).getChannel().h()), obj5);
|
|
}
|
|
linkedHashMap4.put(key2, linkedHashMap5);
|
|
}
|
|
linkedHashMap2.put(key, linkedHashMap4);
|
|
}
|
|
this.activeJoinedThreadsHierarchicalSnapshot = linkedHashMap2;
|
|
}
|
|
}
|