576 lines
26 KiB
Java
576 lines
26 KiB
Java
|
package com.discord.stores;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import c.a.d.q;
|
||
|
import com.discord.api.guild.GuildVerificationLevel;
|
||
|
import com.discord.api.guildmember.GuildMembersChunk;
|
||
|
import com.discord.api.role.GuildRole;
|
||
|
import com.discord.api.utcdatetime.UtcDateTime;
|
||
|
import com.discord.app.AppComponent;
|
||
|
import com.discord.models.domain.ModelPayload;
|
||
|
import com.discord.models.guild.Guild;
|
||
|
import com.discord.models.member.GuildMember;
|
||
|
import com.discord.models.user.MeUser;
|
||
|
import com.discord.stores.updates.ObservationDeck;
|
||
|
import com.discord.stores.updates.ObservationDeckProvider;
|
||
|
import com.discord.utilities.collections.SnowflakePartitionMap;
|
||
|
import com.discord.utilities.guilds.GuildUtilsKt;
|
||
|
import com.discord.utilities.persister.Persister;
|
||
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
||
|
import d0.t.g0;
|
||
|
import d0.t.h0;
|
||
|
import d0.t.n0;
|
||
|
import d0.z.d.m;
|
||
|
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 java.util.Set;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
import kotlin.jvm.functions.Function0;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
import rx.Observable;
|
||
|
/* compiled from: StoreGuilds.kt */
|
||
|
public final class StoreGuilds extends StoreV2 {
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
private static final StoreGuilds$Companion$ComputedMembersUpdate$1 ComputedMembersUpdate = new StoreGuilds$Companion$ComputedMembersUpdate$1();
|
||
|
private static final StoreGuilds$Companion$GuildsUpdate$1 GuildsUpdate = new StoreGuilds$Companion$GuildsUpdate$1();
|
||
|
private static final int HUGE_GUILD_SIZE = 2000;
|
||
|
private static final Map<Long, GuildMember> emptyComputedMap = new HashMap();
|
||
|
private static final Map<Long, GuildRole> emptyRoles = new HashMap();
|
||
|
private final Map<Long, Map<Long, com.discord.api.guildmember.GuildMember>> guildMembers;
|
||
|
private final Map<Long, Map<Long, GuildMember>> guildMembersComputed;
|
||
|
private Map<Long, ? extends Map<Long, GuildMember>> guildMembersComputedSnapshot;
|
||
|
private final Map<Long, Map<Long, GuildRole>> guildRoles;
|
||
|
private final Persister<Map<Long, Map<Long, GuildRole>>> guildRolesCache;
|
||
|
private Map<Long, ? extends Map<Long, GuildRole>> guildRolesSnapshot;
|
||
|
private final Map<Long, Guild> guilds;
|
||
|
private final Persister<Map<Long, Guild>> guildsCache;
|
||
|
private final Map<Long, Long> guildsJoinedAt;
|
||
|
private final Persister<Map<Long, Long>> guildsJoinedAtCache;
|
||
|
private Map<Long, Long> guildsJoinedAtSnapshot;
|
||
|
private Map<Long, Guild> guildsSnapshot;
|
||
|
private final Set<Long> guildsUnavailable;
|
||
|
private Set<Long> guildsUnavailableSnapshot;
|
||
|
private final ObservationDeck observationDeck;
|
||
|
private final StoreUser userStore;
|
||
|
|
||
|
/* compiled from: StoreGuilds.kt */
|
||
|
public static final class Actions {
|
||
|
public static final Actions INSTANCE = new Actions();
|
||
|
|
||
|
private Actions() {
|
||
|
}
|
||
|
|
||
|
public static final void requestMembers(AppComponent appComponent, Observable<String> observable, boolean z2) {
|
||
|
m.checkNotNullParameter(appComponent, "fragment");
|
||
|
m.checkNotNullParameter(observable, "partialUserNameTokenEmitted");
|
||
|
Observable Z = observable.o(1000, TimeUnit.MILLISECONDS).G(new StoreGuilds$Actions$requestMembers$1(z2)).y(StoreGuilds$Actions$requestMembers$2.INSTANCE).s().Z(StoreGuilds$Actions$requestMembers$3.INSTANCE);
|
||
|
m.checkNotNullExpressionValue(Z, "partialUserNameTokenEmit… }\n }");
|
||
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(Z), appComponent, null, 2, null), (Context) null, "requestGuildMembers", (Function1) null, StoreGuilds$Actions$requestMembers$4.INSTANCE, (Function1) null, (Function0) null, (Function0) null, 117, (Object) null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: StoreGuilds.kt */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public StoreGuilds(StoreUser storeUser, ObservationDeck observationDeck) {
|
||
|
m.checkNotNullParameter(storeUser, "userStore");
|
||
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
||
|
this.userStore = storeUser;
|
||
|
this.observationDeck = observationDeck;
|
||
|
this.guildsSnapshot = h0.emptyMap();
|
||
|
this.guildMembersComputedSnapshot = h0.emptyMap();
|
||
|
this.guildRolesSnapshot = h0.emptyMap();
|
||
|
this.guildsUnavailableSnapshot = n0.emptySet();
|
||
|
this.guildsJoinedAtSnapshot = h0.emptyMap();
|
||
|
this.guilds = new HashMap();
|
||
|
this.guildMembersComputed = new HashMap();
|
||
|
this.guildMembers = new HashMap();
|
||
|
this.guildRoles = new HashMap();
|
||
|
this.guildsUnavailable = new HashSet();
|
||
|
this.guildsJoinedAt = new HashMap();
|
||
|
this.guildsCache = new Persister<>("STORE_GUILDS_V34", new HashMap());
|
||
|
this.guildRolesCache = new Persister<>("STORE_GUILD_ROLES_V6", new HashMap());
|
||
|
this.guildsJoinedAtCache = new Persister<>("STORE_GUILD_JOINED_AT_V6", new HashMap());
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
||
|
public /* synthetic */ StoreGuilds(StoreUser storeUser, ObservationDeck observationDeck, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this(storeUser, (i & 2) != 0 ? ObservationDeckProvider.get() : observationDeck);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Map access$getEmptyComputedMap$cp() {
|
||
|
return emptyComputedMap;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Map access$getEmptyRoles$cp() {
|
||
|
return emptyRoles;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void handleGuild(com.discord.api.guild.Guild guild, boolean z2) {
|
||
|
long o = guild.o();
|
||
|
if (!z2) {
|
||
|
Guild guild2 = this.guilds.get(Long.valueOf(o));
|
||
|
if (guild2 == null) {
|
||
|
guild2 = new Guild(null, null, null, null, null, 0, 0, null, 0, null, null, null, false, 0, 0, null, null, null, 0, null, null, 0, 0, 0, null, null, null, null, null, null, null, 0, false, -1, 1, null);
|
||
|
}
|
||
|
Guild merge = guild2.merge(guild);
|
||
|
if (!m.areEqual(merge, this.guilds.get(Long.valueOf(o)))) {
|
||
|
this.guilds.put(Long.valueOf(o), merge);
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
} else if (this.guilds.containsKey(Long.valueOf(o))) {
|
||
|
this.guilds.remove(Long.valueOf(o));
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void handleGuildMember(com.discord.api.guildmember.GuildMember guildMember, long j) {
|
||
|
long i = guildMember.j().i();
|
||
|
if (!this.guildMembers.containsKey(Long.valueOf(j))) {
|
||
|
this.guildMembers.put(Long.valueOf(j), new HashMap());
|
||
|
}
|
||
|
if (!this.guildMembersComputed.containsKey(Long.valueOf(j))) {
|
||
|
this.guildMembersComputed.put(Long.valueOf(j), new HashMap());
|
||
|
}
|
||
|
Map<Long, com.discord.api.guildmember.GuildMember> map = this.guildMembers.get(Long.valueOf(j));
|
||
|
m.checkNotNull(map);
|
||
|
if (!m.areEqual(guildMember, map.get(Long.valueOf(i)))) {
|
||
|
Map<Long, com.discord.api.guildmember.GuildMember> map2 = this.guildMembers.get(Long.valueOf(j));
|
||
|
m.checkNotNull(map2);
|
||
|
map2.put(Long.valueOf(i), guildMember);
|
||
|
}
|
||
|
GuildMember from = GuildMember.Companion.from(this.guildRoles.get(Long.valueOf(j)), guildMember, j);
|
||
|
Map<Long, GuildMember> map3 = this.guildMembersComputed.get(Long.valueOf(j));
|
||
|
m.checkNotNull(map3);
|
||
|
if (!m.areEqual(from, map3.get(Long.valueOf(i)))) {
|
||
|
Map<Long, GuildMember> map4 = this.guildMembersComputed.get(Long.valueOf(j));
|
||
|
m.checkNotNull(map4);
|
||
|
map4.put(Long.valueOf(i), from);
|
||
|
markChanged(ComputedMembersUpdate);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void handleGuildMembers(long j, long j2, Collection<com.discord.api.guildmember.GuildMember> collection, boolean z2) {
|
||
|
if (z2) {
|
||
|
if (j2 > 0) {
|
||
|
Map<Long, com.discord.api.guildmember.GuildMember> map = this.guildMembers.get(Long.valueOf(j));
|
||
|
GuildMember guildMember = null;
|
||
|
if ((map != null ? map.remove(Long.valueOf(j2)) : null) != null) {
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
Map<Long, GuildMember> map2 = this.guildMembersComputed.get(Long.valueOf(j));
|
||
|
if (map2 != null) {
|
||
|
guildMember = map2.remove(Long.valueOf(j2));
|
||
|
}
|
||
|
if (guildMember != null) {
|
||
|
markChanged(ComputedMembersUpdate);
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if (this.guildMembers.remove(Long.valueOf(j)) != null) {
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
if (this.guildMembersComputed.remove(Long.valueOf(j)) != null) {
|
||
|
markChanged(ComputedMembersUpdate);
|
||
|
}
|
||
|
} else if (collection != null) {
|
||
|
for (com.discord.api.guildmember.GuildMember guildMember2 : collection) {
|
||
|
handleGuildMember(guildMember2, j);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void handleGuildMembersMap(long j, Map<Long, com.discord.api.guildmember.GuildMember> map) {
|
||
|
handleGuildMembers(j, 0, map != null ? map.values() : null, false);
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void handleGuildRoles(long j, long j2, List<GuildRole> list, boolean z2) {
|
||
|
if (!z2) {
|
||
|
Map<Long, Map<Long, GuildRole>> map = this.guildRoles;
|
||
|
Long valueOf = Long.valueOf(j);
|
||
|
Map<Long, GuildRole> map2 = map.get(valueOf);
|
||
|
if (map2 == null) {
|
||
|
map2 = new HashMap<>();
|
||
|
map.put(valueOf, map2);
|
||
|
}
|
||
|
Map<Long, GuildRole> map3 = map2;
|
||
|
if (list != null) {
|
||
|
for (GuildRole guildRole : list) {
|
||
|
if (!m.areEqual(map3.get(Long.valueOf(guildRole.getId())), guildRole)) {
|
||
|
map3.put(Long.valueOf(guildRole.getId()), guildRole);
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
} else if (j2 > 0) {
|
||
|
Map<Long, GuildRole> map4 = this.guildRoles.get(Long.valueOf(j));
|
||
|
if ((map4 != null ? map4.remove(Long.valueOf(j2)) : null) != null) {
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
} else if (this.guildRoles.containsKey(Long.valueOf(j))) {
|
||
|
this.guildRoles.remove(Long.valueOf(j));
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void handleGuildUnavailable(long j, boolean z2, boolean z3) {
|
||
|
if (z3) {
|
||
|
if (z2 && !this.guildsUnavailable.contains(Long.valueOf(j))) {
|
||
|
this.guildsUnavailable.add(Long.valueOf(j));
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
} else if (!z2 && this.guildsUnavailable.contains(Long.valueOf(j))) {
|
||
|
this.guildsUnavailable.remove(Long.valueOf(j));
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void handleHasRoleAndJoinedAt(long j, Map<Long, com.discord.api.guildmember.GuildMember> map) {
|
||
|
com.discord.api.guildmember.GuildMember guildMember;
|
||
|
Long l;
|
||
|
MeUser meInternal$app_productionBetaRelease = this.userStore.getMeInternal$app_productionBetaRelease();
|
||
|
if (map != null && (guildMember = map.get(Long.valueOf(meInternal$app_productionBetaRelease.getId()))) != null) {
|
||
|
UtcDateTime d = guildMember.d();
|
||
|
long f = d != null ? d.f() : 0;
|
||
|
if (!this.guildsJoinedAt.containsKey(Long.valueOf(j)) || (l = this.guildsJoinedAt.get(Long.valueOf(j))) == null || l.longValue() != f) {
|
||
|
this.guildsJoinedAt.put(Long.valueOf(j), Long.valueOf(f));
|
||
|
markChanged(GuildsUpdate);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final Guild getGuild(long j) {
|
||
|
return this.guildsSnapshot.get(Long.valueOf(j));
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final Map<Long, Map<Long, GuildMember>> getGuildMembersComputedInternal$app_productionBetaRelease() {
|
||
|
return this.guildMembersComputed;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final Map<Long, Map<Long, GuildRole>> getGuildRolesInternal$app_productionBetaRelease() {
|
||
|
return this.guildRoles;
|
||
|
}
|
||
|
|
||
|
public final Map<Long, Guild> getGuilds() {
|
||
|
return this.guildsSnapshot;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final Map<Long, Guild> getGuildsInternal$app_productionBetaRelease() {
|
||
|
return this.guilds;
|
||
|
}
|
||
|
|
||
|
public final Map<Long, Long> getGuildsJoinedAt() {
|
||
|
return this.guildsJoinedAtSnapshot;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final Map<Long, Long> getGuildsJoinedAtInternal$app_productionBetaRelease() {
|
||
|
return this.guildsJoinedAt;
|
||
|
}
|
||
|
|
||
|
public final GuildMember getMember(long j, long j2) {
|
||
|
Map map = (Map) this.guildMembersComputedSnapshot.get(Long.valueOf(j));
|
||
|
if (map != null) {
|
||
|
return (GuildMember) map.get(Long.valueOf(j2));
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: java.util.Map<java.lang.Long, ? extends java.util.Map<java.lang.Long, com.discord.models.member.GuildMember>>, java.util.Map<java.lang.Long, java.util.Map<java.lang.Long, com.discord.models.member.GuildMember>> */
|
||
|
public final Map<Long, Map<Long, GuildMember>> getMembers() {
|
||
|
return this.guildMembersComputedSnapshot;
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: java.util.Map<java.lang.Long, ? extends java.util.Map<java.lang.Long, com.discord.api.role.GuildRole>>, java.util.Map<java.lang.Long, java.util.Map<java.lang.Long, com.discord.api.role.GuildRole>> */
|
||
|
public final Map<Long, Map<Long, GuildRole>> getRoles() {
|
||
|
return this.guildRolesSnapshot;
|
||
|
}
|
||
|
|
||
|
public final Set<Long> getUnavailableGuilds() {
|
||
|
return this.guildsUnavailableSnapshot;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final Set<Long> getUnavailableGuildsInternal$app_productionBetaRelease() {
|
||
|
return this.guildsUnavailable;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleConnectionOpen(ModelPayload modelPayload) {
|
||
|
Map<Long, com.discord.api.guildmember.GuildMember> map;
|
||
|
m.checkNotNullParameter(modelPayload, "payload");
|
||
|
this.guilds.clear();
|
||
|
this.guildMembers.clear();
|
||
|
this.guildMembersComputed.clear();
|
||
|
this.guildRoles.clear();
|
||
|
this.guildsUnavailable.clear();
|
||
|
for (com.discord.api.guild.Guild guild : modelPayload.getGuilds()) {
|
||
|
long o = guild.o();
|
||
|
if (guild.L()) {
|
||
|
this.guildsUnavailable.add(Long.valueOf(o));
|
||
|
} else {
|
||
|
handleGuildRoles(o, 0, guild.D(), false);
|
||
|
m.checkNotNullExpressionValue(guild, "guild");
|
||
|
handleGuild(guild, false);
|
||
|
List<com.discord.api.guildmember.GuildMember> s2 = guild.s();
|
||
|
if (s2 == null || (map = GuildUtilsKt.asMap(s2)) == null) {
|
||
|
map = h0.emptyMap();
|
||
|
}
|
||
|
handleGuildMembersMap(o, map);
|
||
|
handleHasRoleAndJoinedAt(o, map);
|
||
|
}
|
||
|
}
|
||
|
markChanged(GuildsUpdate, ComputedMembersUpdate);
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleGuildAdd(com.discord.api.guild.Guild guild) {
|
||
|
Map<Long, com.discord.api.guildmember.GuildMember> map;
|
||
|
m.checkNotNullParameter(guild, "guild");
|
||
|
handleGuildUnavailable(guild.o(), guild.L(), false);
|
||
|
if (!guild.L()) {
|
||
|
handleGuildRoles(guild.o(), 0, guild.D(), false);
|
||
|
handleGuild(guild, false);
|
||
|
List<com.discord.api.guildmember.GuildMember> s2 = guild.s();
|
||
|
if (s2 == null || (map = GuildUtilsKt.asMap(s2)) == null) {
|
||
|
map = h0.emptyMap();
|
||
|
}
|
||
|
handleGuildMembersMap(guild.o(), map);
|
||
|
handleHasRoleAndJoinedAt(guild.o(), map);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleGuildMemberAdd(com.discord.api.guildmember.GuildMember guildMember) {
|
||
|
m.checkNotNullParameter(guildMember, "member");
|
||
|
handleGuildMember(guildMember, guildMember.c());
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleGuildMemberRemove(long j, long j2) {
|
||
|
handleGuildMembers(j, j2, null, true);
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleGuildMembersChunk(GuildMembersChunk guildMembersChunk) {
|
||
|
m.checkNotNullParameter(guildMembersChunk, "chunk");
|
||
|
handleGuildMembers(guildMembersChunk.a(), 0, guildMembersChunk.b(), false);
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleGuildRemove(com.discord.api.guild.Guild guild) {
|
||
|
m.checkNotNullParameter(guild, "guild");
|
||
|
handleGuildUnavailable(guild.o(), guild.L(), true);
|
||
|
handleGuild(guild, true);
|
||
|
handleGuildRoles(guild.o(), 0, null, true);
|
||
|
handleGuildMembers(guild.o(), 0, null, true);
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleGuildRoleCreateOrUpdate(long j, GuildRole guildRole) {
|
||
|
m.checkNotNullParameter(guildRole, "role");
|
||
|
handleGuildRoles(j, 0, d0.t.m.listOf(guildRole), false);
|
||
|
handleGuildMembersMap(j, this.guildMembers.get(Long.valueOf(j)));
|
||
|
handleHasRoleAndJoinedAt(j, this.guildMembers.get(Long.valueOf(j)));
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleGuildRoleRemove(long j, long j2) {
|
||
|
handleGuildRoles(j2, j, null, true);
|
||
|
handleGuildMembersMap(j2, this.guildMembers.get(Long.valueOf(j2)));
|
||
|
handleHasRoleAndJoinedAt(j2, this.guildMembers.get(Long.valueOf(j2)));
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.stores.Store
|
||
|
public void init(Context context) {
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
this.guilds.putAll(this.guildsCache.get());
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||
|
Iterator<Map.Entry<Long, Map<Long, GuildRole>>> it = this.guildRolesCache.get().entrySet().iterator();
|
||
|
while (true) {
|
||
|
boolean z2 = true;
|
||
|
if (!it.hasNext()) {
|
||
|
break;
|
||
|
}
|
||
|
Map.Entry<Long, Map<Long, GuildRole>> next = it.next();
|
||
|
if (next.getKey() == null) {
|
||
|
z2 = false;
|
||
|
}
|
||
|
if (z2) {
|
||
|
linkedHashMap.put(next.getKey(), next.getValue());
|
||
|
}
|
||
|
}
|
||
|
for (Map.Entry entry : linkedHashMap.entrySet()) {
|
||
|
this.guildRoles.put(Long.valueOf(((Number) entry.getKey()).longValue()), h0.toMutableMap((Map) entry.getValue()));
|
||
|
}
|
||
|
this.guildsJoinedAt.putAll(this.guildsJoinedAtCache.get());
|
||
|
markChanged(GuildsUpdate, ComputedMembersUpdate);
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, Map<Long, GuildMember>>> observeComputed() {
|
||
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{ComputedMembersUpdate}, false, null, null, new StoreGuilds$observeComputed$1(this), 14, null);
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, GuildMember>> observeComputed(long j) {
|
||
|
Observable<Map<Long, GuildMember>> s2 = observeComputed().G(new StoreGuilds$observeComputed$2(j)).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observeComputed()\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, GuildMember>> observeComputed(long j, Collection<Long> collection) {
|
||
|
m.checkNotNullParameter(collection, "userIds");
|
||
|
Observable<R> k = observeComputed(j).k(q.a(collection));
|
||
|
m.checkNotNullExpressionValue(k, "observeComputed(guildId)…mpose(filterMap(userIds))");
|
||
|
return k;
|
||
|
}
|
||
|
|
||
|
public final Observable<GuildMember> observeComputedMember(long j, long j2) {
|
||
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{ComputedMembersUpdate}, false, null, null, new StoreGuilds$observeComputedMember$1(this, j, j2), 14, null);
|
||
|
}
|
||
|
|
||
|
public final Observable<Guild> observeFromChannelId(long j) {
|
||
|
Observable<R> Z = StoreStream.Companion.getChannels().observeChannel(j).Z(new StoreGuilds$observeFromChannelId$1(this));
|
||
|
m.checkNotNullExpressionValue(Z, "StoreStream\n .get…ll)\n }\n }");
|
||
|
return Z;
|
||
|
}
|
||
|
|
||
|
public final Observable<Guild> observeGuild(long j) {
|
||
|
Observable<Guild> s2 = observeGuilds().G(new StoreGuilds$observeGuild$1(j)).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observeGuilds()\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Set<Long>> observeGuildIds() {
|
||
|
Observable<Set<Long>> s2 = observeGuilds().Z(StoreGuilds$observeGuildIds$1.INSTANCE).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observeGuilds()\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<GuildMember> observeGuildMember(long j, long j2) {
|
||
|
return observeComputed().G(new StoreGuilds$observeGuildMember$1(j, j2)).s();
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, GuildMember>> observeGuildMembers(long j) {
|
||
|
return observeComputed().G(new StoreGuilds$observeGuildMembers$1(j)).s();
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, Guild>> observeGuilds() {
|
||
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{GuildsUpdate}, false, null, null, new StoreGuilds$observeGuilds$1(this), 14, null);
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, Long>> observeJoinedAt() {
|
||
|
Observable<Map<Long, Long>> s2 = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{GuildsUpdate}, false, null, null, new StoreGuilds$observeJoinedAt$1(this), 14, null).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observationDeck\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Long> observeJoinedAt(long j) {
|
||
|
Observable<Long> s2 = observeJoinedAt().G(new StoreGuilds$observeJoinedAt$2(j)).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observeJoinedAt()\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, Map<Long, GuildRole>>> observeRoles() {
|
||
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{GuildsUpdate}, false, null, null, new StoreGuilds$observeRoles$1(this), 14, null);
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, GuildRole>> observeRoles(long j) {
|
||
|
Observable<Map<Long, GuildRole>> s2 = observeRoles().G(new StoreGuilds$observeRoles$2(j)).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observeRoles()\n .… .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, GuildRole>> observeRoles(long j, Collection<Long> collection) {
|
||
|
m.checkNotNullParameter(collection, "roleIds");
|
||
|
Observable<R> k = observeRoles(j).k(q.a(collection));
|
||
|
m.checkNotNullExpressionValue(k, "observeRoles(guildId)\n …mpose(filterMap(roleIds))");
|
||
|
return k;
|
||
|
}
|
||
|
|
||
|
public final Observable<List<GuildRole>> observeSortedRoles(long j) {
|
||
|
Observable<List<GuildRole>> s2 = observeRoles(j).Z(StoreGuilds$observeSortedRoles$1.INSTANCE).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observeRoles(guildId)\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Set<Long>> observeUnavailableGuilds() {
|
||
|
Observable<Set<Long>> s2 = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{GuildsUpdate}, false, null, null, new StoreGuilds$observeUnavailableGuilds$1(this), 14, null).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observationDeck\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<GuildVerificationLevel> observeVerificationLevel(long j) {
|
||
|
Observable<GuildVerificationLevel> s2 = observeGuild(j).G(StoreGuilds$observeVerificationLevel$1.INSTANCE).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observeGuild(guildId)\n … .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.stores.StoreV2
|
||
|
@StoreThread
|
||
|
public void snapshotData() {
|
||
|
SnowflakePartitionMap.CopiablePartitionMap copiablePartitionMap;
|
||
|
super.snapshotData();
|
||
|
if (getUpdateSources().contains(GuildsUpdate)) {
|
||
|
HashMap hashMap = new HashMap(this.guildsJoinedAt);
|
||
|
this.guildsJoinedAtSnapshot = hashMap;
|
||
|
Persister.set$default(this.guildsJoinedAtCache, hashMap, false, 2, null);
|
||
|
this.guildsSnapshot = new HashMap(this.guilds);
|
||
|
Persister.set$default(this.guildsCache, h0.minus((Map) this.guilds, (Iterable) StoreStream.Companion.getLurking().getLurkingGuildIdsSync()), false, 2, null);
|
||
|
this.guildsUnavailableSnapshot = new HashSet(this.guildsUnavailable);
|
||
|
Map<Long, Map<Long, GuildRole>> map = this.guildRoles;
|
||
|
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(), new HashMap((Map) entry.getValue()));
|
||
|
}
|
||
|
this.guildRolesSnapshot = linkedHashMap;
|
||
|
Persister.set$default(this.guildRolesCache, linkedHashMap, false, 2, null);
|
||
|
}
|
||
|
if (getUpdateSources().contains(ComputedMembersUpdate)) {
|
||
|
HashMap hashMap2 = new HashMap();
|
||
|
for (Map.Entry<Long, Map<Long, GuildMember>> entry2 : this.guildMembersComputed.entrySet()) {
|
||
|
Map<Long, GuildMember> value = entry2.getValue();
|
||
|
if (value.size() < 2000) {
|
||
|
hashMap2.put(entry2.getKey(), new HashMap(value));
|
||
|
} else {
|
||
|
if (value instanceof SnowflakePartitionMap.CopiablePartitionMap) {
|
||
|
copiablePartitionMap = (SnowflakePartitionMap.CopiablePartitionMap) value;
|
||
|
} else {
|
||
|
SnowflakePartitionMap.CopiablePartitionMap copiablePartitionMap2 = new SnowflakePartitionMap.CopiablePartitionMap(0, 1, null);
|
||
|
copiablePartitionMap2.putAll(value);
|
||
|
entry2.setValue(copiablePartitionMap2);
|
||
|
copiablePartitionMap = copiablePartitionMap2;
|
||
|
}
|
||
|
hashMap2.put(entry2.getKey(), copiablePartitionMap.fastCopy());
|
||
|
}
|
||
|
}
|
||
|
this.guildMembersComputedSnapshot = hashMap2;
|
||
|
}
|
||
|
}
|
||
|
}
|