560 lines
27 KiB
Java
560 lines
27 KiB
Java
package com.discord.stores;
|
|
|
|
import android.content.Context;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.permission.PermissionOverwrite;
|
|
import com.discord.api.role.GuildRole;
|
|
import com.discord.app.AppLog;
|
|
import com.discord.models.domain.ModelGuildMemberListUpdate;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.presence.Presence;
|
|
import com.discord.models.user.User;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.utilities.PermissionOverwriteUtilsKt;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.lazy.memberlist.ChannelMemberList;
|
|
import com.discord.utilities.lazy.memberlist.MemberListRow;
|
|
import com.discord.utilities.logging.Logger;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.user.UserUtils;
|
|
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
|
import d0.t.g0;
|
|
import d0.t.h0;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
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 java.util.concurrent.TimeUnit;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.ranges.IntRange;
|
|
import rx.Observable;
|
|
import rx.subjects.PublishSubject;
|
|
/* compiled from: StoreChannelMembers.kt */
|
|
public final class StoreChannelMembers extends StoreV2 {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final Dispatcher dispatcher;
|
|
private final Function1<Long, Channel> getChannel;
|
|
private final Function1<Long, Integer> getGuildMemberCount;
|
|
private final Function1<Long, Presence> getPresence;
|
|
private final Function1<Long, Boolean> isUserStreaming;
|
|
private final PublishSubject<Unit> markChangedTrigger;
|
|
private final Map<Long, Map<String, ChannelMemberList>> memberLists = new LinkedHashMap();
|
|
private Map<Long, ? extends Map<String, ChannelMemberList>> memberListsSnapshot = h0.emptyMap();
|
|
private final ObservationDeck observationDeck;
|
|
private final StoreGuilds storeGuilds;
|
|
private final StoreUser storeUser;
|
|
|
|
/* compiled from: StoreChannelMembers.kt */
|
|
/* renamed from: com.discord.stores.StoreChannelMembers$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<Unit, Unit> {
|
|
public final /* synthetic */ StoreChannelMembers this$0;
|
|
|
|
/* compiled from: StoreChannelMembers.kt */
|
|
/* renamed from: com.discord.stores.StoreChannelMembers$1$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function0<Unit> {
|
|
public final /* synthetic */ AnonymousClass1 this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(AnonymousClass1 r1) {
|
|
super(0);
|
|
this.this$0 = r1;
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke */
|
|
public final void mo1invoke() {
|
|
this.this$0.this$0.markChanged();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(StoreChannelMembers storeChannelMembers) {
|
|
super(1);
|
|
this.this$0 = storeChannelMembers;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(Unit unit) {
|
|
invoke(unit);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(Unit unit) {
|
|
StoreChannelMembers.access$getDispatcher$p(this.this$0).schedule(new AnonymousClass1(this));
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelMembers.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final MemberListRow.Member makeRowMember(long j, Map<Long, GuildMember> map, Map<Long, ? extends User> map2, Presence presence, boolean z2, boolean z3) {
|
|
m.checkNotNullParameter(map2, "users");
|
|
Integer num = null;
|
|
GuildMember guildMember = map != null ? map.get(Long.valueOf(j)) : null;
|
|
User user = (User) map2.get(Long.valueOf(j));
|
|
if (user == null || guildMember == null) {
|
|
return null;
|
|
}
|
|
if (guildMember.getColor() != -16777216) {
|
|
num = Integer.valueOf(guildMember.getColor());
|
|
}
|
|
return new MemberListRow.Member(j, GuildMember.Companion.getNickOrUsername(guildMember, user), user.isBot(), Integer.valueOf(user.isSystemUser() ? 2131893822 : 2131887051), UserUtils.INSTANCE.isVerifiedBot(user), presence, num, IconUtils.getForGuildMemberOrUser$default(IconUtils.INSTANCE, user, guildMember, null, 4, null), z3, guildMember.getPremiumSince(), z2);
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelMembers.kt */
|
|
public static final class MemberListIdCalculator {
|
|
public static final MemberListIdCalculator INSTANCE = new MemberListIdCalculator();
|
|
|
|
private MemberListIdCalculator() {
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:17:0x007d A[ORIG_RETURN, RETURN, SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:26:? A[RETURN, SYNTHETIC] */
|
|
private final String computeIdFromOverwrites(List<PermissionOverwrite> list) {
|
|
String str;
|
|
String joinToString$default;
|
|
if (list != null) {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (PermissionOverwrite permissionOverwrite : list) {
|
|
if (PermissionOverwriteUtilsKt.allows(permissionOverwrite, 1024)) {
|
|
StringBuilder L = a.L("allow:");
|
|
L.append(permissionOverwrite.e());
|
|
arrayList.add(L.toString());
|
|
} else if (PermissionOverwriteUtilsKt.denies(permissionOverwrite, 1024)) {
|
|
StringBuilder L2 = a.L("deny:");
|
|
L2.append(permissionOverwrite.e());
|
|
arrayList.add(L2.toString());
|
|
}
|
|
}
|
|
List sorted = u.sorted(arrayList);
|
|
if (!(sorted == null || (joinToString$default = u.joinToString$default(sorted, ",", null, null, 0, null, null, 62, null)) == null)) {
|
|
str = String.valueOf(INSTANCE.toUnsignedLong(c.q.a.k.a.H(joinToString$default, 0, joinToString$default.length(), 0)));
|
|
return str == null ? str : "";
|
|
}
|
|
}
|
|
str = null;
|
|
if (str == null) {
|
|
}
|
|
}
|
|
|
|
private final long toUnsignedLong(int i) {
|
|
return ((long) i) & 4294967295L;
|
|
}
|
|
|
|
public final String computeMemberListId(Function1<? super Long, Channel> function1, long j, StoreGuilds storeGuilds) {
|
|
m.checkNotNullParameter(function1, "channelsProvider");
|
|
m.checkNotNullParameter(storeGuilds, "storeGuilds");
|
|
Channel invoke = function1.invoke(Long.valueOf(j));
|
|
String k = invoke != null ? invoke.k() : null;
|
|
if (invoke != null) {
|
|
if (k != null) {
|
|
return k;
|
|
}
|
|
Map map = (Map) a.c(invoke, storeGuilds.getRoles());
|
|
if (map == null) {
|
|
map = h0.emptyMap();
|
|
}
|
|
if (!PermissionUtils.canEveryone(1024, invoke, null, map)) {
|
|
return computeIdFromOverwrites(invoke.s());
|
|
}
|
|
}
|
|
return "everyone";
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelMembers.kt */
|
|
public static final class MemberListUpdateException extends RuntimeException {
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public MemberListUpdateException(Exception exc) {
|
|
super(exc);
|
|
m.checkNotNullParameter(exc, "e");
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreChannelMembers.kt */
|
|
public static final class MemberListUpdateLogger {
|
|
private static final String ERROR_TAG = "MemberListUpdateError";
|
|
public static final MemberListUpdateLogger INSTANCE = new MemberListUpdateLogger();
|
|
private static final int MAX_UPDATE_COUNT = 20;
|
|
private static final Map<String, List<String>> opLogs = new HashMap();
|
|
|
|
private MemberListUpdateLogger() {
|
|
}
|
|
|
|
private final String makeLogKey(long j, String str) {
|
|
return j + ':' + str;
|
|
}
|
|
|
|
public final void dumpLogs(long j, String str, Exception exc) {
|
|
m.checkNotNullParameter(str, "memberListId");
|
|
m.checkNotNullParameter(exc, "exception");
|
|
List<String> list = opLogs.get(makeLogKey(j, str));
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("guildId: ");
|
|
sb.append(j);
|
|
sb.append(" -- memberListId: ");
|
|
sb.append(str);
|
|
sb.append(" -- LAST 20 UPDATES:\n");
|
|
sb.append(list != null ? u.joinToString$default(list, "\n", null, null, 0, null, null, 62, null) : null);
|
|
FirebaseCrashlytics.getInstance().log(sb.toString());
|
|
Logger.e$default(AppLog.g, "MemberListUpdateError", new MemberListUpdateException(exc), null, 4, null);
|
|
}
|
|
|
|
public final void logUpdate(ModelGuildMemberListUpdate modelGuildMemberListUpdate) {
|
|
String str;
|
|
m.checkNotNullParameter(modelGuildMemberListUpdate, "update");
|
|
List<ModelGuildMemberListUpdate.Operation> operations = modelGuildMemberListUpdate.getOperations();
|
|
ArrayList arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(operations, 10));
|
|
for (ModelGuildMemberListUpdate.Operation operation : operations) {
|
|
if (operation instanceof ModelGuildMemberListUpdate.Operation.Sync) {
|
|
StringBuilder L = a.L(" SYNC: ");
|
|
L.append(((ModelGuildMemberListUpdate.Operation.Sync) operation).getRange());
|
|
str = L.toString();
|
|
} else if (operation instanceof ModelGuildMemberListUpdate.Operation.Update) {
|
|
StringBuilder L2 = a.L(" UPDATE: ");
|
|
L2.append(((ModelGuildMemberListUpdate.Operation.Update) operation).getIndex());
|
|
str = L2.toString();
|
|
} else if (operation instanceof ModelGuildMemberListUpdate.Operation.Insert) {
|
|
StringBuilder L3 = a.L(" INSERT: ");
|
|
L3.append(((ModelGuildMemberListUpdate.Operation.Insert) operation).getIndex());
|
|
str = L3.toString();
|
|
} else if (operation instanceof ModelGuildMemberListUpdate.Operation.Delete) {
|
|
StringBuilder L4 = a.L(" DELETE: ");
|
|
L4.append(((ModelGuildMemberListUpdate.Operation.Delete) operation).getIndex());
|
|
str = L4.toString();
|
|
} else if (operation instanceof ModelGuildMemberListUpdate.Operation.Invalidate) {
|
|
StringBuilder L5 = a.L(" INVALIDATE: ");
|
|
L5.append(((ModelGuildMemberListUpdate.Operation.Invalidate) operation).getRange());
|
|
str = L5.toString();
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
arrayList.add(str);
|
|
}
|
|
String D = a.D(a.L("GROUPS: ["), u.joinToString$default(modelGuildMemberListUpdate.getGroups(), ",", null, null, 0, null, StoreChannelMembers$MemberListUpdateLogger$logUpdate$groupLog$1.INSTANCE, 30, null), "]");
|
|
ArrayList arrayList2 = new ArrayList();
|
|
arrayList2.addAll(arrayList);
|
|
arrayList2.add(D);
|
|
arrayList2.add("-----");
|
|
String makeLogKey = makeLogKey(modelGuildMemberListUpdate.getGuildId(), modelGuildMemberListUpdate.getId());
|
|
Map<String, List<String>> map = opLogs;
|
|
List<String> list = map.get(makeLogKey);
|
|
if (list == null) {
|
|
list = new ArrayList<>();
|
|
}
|
|
list.add(u.joinToString$default(arrayList2, "\n", null, null, 0, null, null, 62, null));
|
|
if (list.size() > 20) {
|
|
list.remove(0);
|
|
}
|
|
map.put(makeLogKey, list);
|
|
}
|
|
}
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
ModelGuildMemberListUpdate.Group.Type.values();
|
|
int[] iArr = new int[3];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[ModelGuildMemberListUpdate.Group.Type.ROLE.ordinal()] = 1;
|
|
iArr[ModelGuildMemberListUpdate.Group.Type.OFFLINE.ordinal()] = 2;
|
|
iArr[ModelGuildMemberListUpdate.Group.Type.ONLINE.ordinal()] = 3;
|
|
}
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r20v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.Long, com.discord.api.channel.Channel> */
|
|
/* JADX DEBUG: Multi-variable search result rejected for r21v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Integer> */
|
|
/* JADX DEBUG: Multi-variable search result rejected for r22v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.Long, com.discord.models.presence.Presence> */
|
|
/* JADX DEBUG: Multi-variable search result rejected for r23v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Boolean> */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public StoreChannelMembers(ObservationDeck observationDeck, Dispatcher dispatcher, StoreGuilds storeGuilds, StoreUser storeUser, Function1<? super Long, Channel> function1, Function1<? super Long, Integer> function12, Function1<? super Long, Presence> function13, Function1<? super Long, Boolean> function14) {
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
|
m.checkNotNullParameter(storeGuilds, "storeGuilds");
|
|
m.checkNotNullParameter(storeUser, "storeUser");
|
|
m.checkNotNullParameter(function1, "getChannel");
|
|
m.checkNotNullParameter(function12, "getGuildMemberCount");
|
|
m.checkNotNullParameter(function13, "getPresence");
|
|
m.checkNotNullParameter(function14, "isUserStreaming");
|
|
this.observationDeck = observationDeck;
|
|
this.dispatcher = dispatcher;
|
|
this.storeGuilds = storeGuilds;
|
|
this.storeUser = storeUser;
|
|
this.getChannel = function1;
|
|
this.getGuildMemberCount = function12;
|
|
this.getPresence = function13;
|
|
this.isUserStreaming = function14;
|
|
PublishSubject<Unit> k0 = PublishSubject.k0();
|
|
this.markChangedTrigger = k0;
|
|
m.checkNotNullExpressionValue(k0, "markChangedTrigger");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.leadingEdgeThrottle(k0, 1, TimeUnit.SECONDS), StoreChannelMembers.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
}
|
|
|
|
public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreChannelMembers storeChannelMembers) {
|
|
return storeChannelMembers.dispatcher;
|
|
}
|
|
|
|
public static final /* synthetic */ MemberListRow access$makeGroup(StoreChannelMembers storeChannelMembers, long j, ModelGuildMemberListUpdate.Group group) {
|
|
return storeChannelMembers.makeGroup(j, group);
|
|
}
|
|
|
|
public static final /* synthetic */ MemberListRow access$makeRowMember(StoreChannelMembers storeChannelMembers, long j, long j2, boolean z2) {
|
|
return storeChannelMembers.makeRowMember(j, j2, z2);
|
|
}
|
|
|
|
@StoreThread
|
|
private final boolean allowOwnerIndicator(long j) {
|
|
Collection<GuildRole> values;
|
|
boolean z2;
|
|
Map<Long, GuildRole> map = this.storeGuilds.getGuildRolesInternal$app_productionBetaRelease().get(Long.valueOf(j));
|
|
boolean z3 = false;
|
|
if (map != null && (values = map.values()) != null && !values.isEmpty()) {
|
|
Iterator<T> it = values.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
GuildRole guildRole = (GuildRole) it.next();
|
|
if (!guildRole.c() || !PermissionUtils.can(8, Long.valueOf(guildRole.g()))) {
|
|
z2 = false;
|
|
continue;
|
|
} else {
|
|
z2 = true;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
z3 = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return !z3;
|
|
}
|
|
|
|
@StoreThread
|
|
private final ChannelMemberList getMemberList(long j, String str) {
|
|
Map<String, ChannelMemberList> map = this.memberLists.get(Long.valueOf(j));
|
|
if (map != null) {
|
|
return map.get(str);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleDelete(String str, ModelGuildMemberListUpdate.Operation.Delete delete, long j) {
|
|
ChannelMemberList memberList = getMemberList(j, str);
|
|
if (memberList != null) {
|
|
memberList.delete(delete.getIndex());
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleInsert(String str, ModelGuildMemberListUpdate.Operation.Insert insert, long j) {
|
|
int index = insert.getIndex();
|
|
ChannelMemberList memberList = getMemberList(j, str);
|
|
if (memberList != null) {
|
|
memberList.insert(index, makeRow(j, insert.getItem()));
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleInvalidate(String str, ModelGuildMemberListUpdate.Operation.Invalidate invalidate, long j) {
|
|
IntRange range = invalidate.getRange();
|
|
ChannelMemberList memberList = getMemberList(j, str);
|
|
if (memberList != null) {
|
|
memberList.invalidate(range);
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleSync(String str, ModelGuildMemberListUpdate.Operation.Sync sync, long j) {
|
|
MemberListRow memberListRow;
|
|
Map<String, ChannelMemberList> map = this.memberLists.get(Long.valueOf(j));
|
|
if (map == null) {
|
|
map = new HashMap<>();
|
|
this.memberLists.put(Long.valueOf(j), map);
|
|
}
|
|
ChannelMemberList channelMemberList = map.get(str);
|
|
if (channelMemberList == null) {
|
|
AppLog appLog = AppLog.g;
|
|
channelMemberList = new ChannelMemberList(str, 0, appLog, 2, null);
|
|
map.put(str, channelMemberList);
|
|
appLog.recordBreadcrumb(channelMemberList.getListId() + " INSTANTIATE", "ChannelMemberList");
|
|
}
|
|
boolean allowOwnerIndicator = allowOwnerIndicator(j);
|
|
List<ModelGuildMemberListUpdate.Operation.Item> items = sync.getItems();
|
|
ArrayList arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(items, 10));
|
|
for (ModelGuildMemberListUpdate.Operation.Item item : items) {
|
|
if (item instanceof ModelGuildMemberListUpdate.Operation.Item.MemberItem) {
|
|
memberListRow = makeRowMember(j, ((ModelGuildMemberListUpdate.Operation.Item.MemberItem) item).getMember().j().i(), allowOwnerIndicator);
|
|
} else if (item instanceof ModelGuildMemberListUpdate.Operation.Item.GroupItem) {
|
|
memberListRow = makeGroup(j, ((ModelGuildMemberListUpdate.Operation.Item.GroupItem) item).getGroup());
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
arrayList.add(memberListRow);
|
|
}
|
|
channelMemberList.sync(((Number) u.first(sync.getRange())).intValue(), arrayList);
|
|
}
|
|
|
|
private final void handleUpdate(String str, ModelGuildMemberListUpdate.Operation.Update update, long j) {
|
|
int index = update.getIndex();
|
|
ChannelMemberList memberList = getMemberList(j, str);
|
|
if (memberList != null) {
|
|
memberList.update(index, makeRow(j, update.getItem()));
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
private final MemberListRow makeGroup(long j, ModelGuildMemberListUpdate.Group group) {
|
|
String str;
|
|
GuildRole guildRole;
|
|
String id2 = group.getId();
|
|
int ordinal = group.getType().ordinal();
|
|
if (ordinal == 0) {
|
|
long parseLong = Long.parseLong(id2);
|
|
Map<Long, GuildRole> map = this.storeGuilds.getGuildRolesInternal$app_productionBetaRelease().get(Long.valueOf(j));
|
|
if (map == null || (guildRole = map.get(Long.valueOf(parseLong))) == null || (str = guildRole.f()) == null) {
|
|
str = "";
|
|
}
|
|
return new MemberListRow.RoleHeader(parseLong, str, group.getCount());
|
|
} else if (ordinal == 1) {
|
|
return new MemberListRow.StatusHeader(id2, MemberListRow.StatusHeader.Type.OFFLINE, group.getCount());
|
|
} else {
|
|
if (ordinal == 2) {
|
|
return new MemberListRow.StatusHeader(id2, MemberListRow.StatusHeader.Type.ONLINE, group.getCount());
|
|
}
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
private final MemberListRow makeRow(long j, ModelGuildMemberListUpdate.Operation.Item item) {
|
|
if (item instanceof ModelGuildMemberListUpdate.Operation.Item.MemberItem) {
|
|
return makeRowMember(j, ((ModelGuildMemberListUpdate.Operation.Item.MemberItem) item).getMember().j().i(), allowOwnerIndicator(j));
|
|
}
|
|
if (item instanceof ModelGuildMemberListUpdate.Operation.Item.GroupItem) {
|
|
return makeGroup(j, ((ModelGuildMemberListUpdate.Operation.Item.GroupItem) item).getGroup());
|
|
}
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
|
|
@StoreThread
|
|
private final MemberListRow makeRowMember(long j, long j2, boolean z2) {
|
|
Guild guild;
|
|
return Companion.makeRowMember(j2, this.storeGuilds.getGuildMembersComputedInternal$app_productionBetaRelease().get(Long.valueOf(j)), this.storeUser.getUsersInternal$app_productionBetaRelease(), this.getPresence.invoke(Long.valueOf(j2)), this.isUserStreaming.invoke(Long.valueOf(j2)).booleanValue(), z2 && (guild = this.storeGuilds.getGuildsInternal$app_productionBetaRelease().get(Long.valueOf(j))) != null && guild.getOwnerId() == j2);
|
|
}
|
|
|
|
private final void throttleMarkChanged() {
|
|
PublishSubject<Unit> publishSubject = this.markChangedTrigger;
|
|
publishSubject.j.onNext(Unit.a);
|
|
}
|
|
|
|
public final ChannelMemberList getChannelMemberList(long j, long j2) {
|
|
String computeMemberListId = MemberListIdCalculator.INSTANCE.computeMemberListId(this.getChannel, j2, this.storeGuilds);
|
|
Map map = (Map) this.memberListsSnapshot.get(Long.valueOf(j));
|
|
if (map == null) {
|
|
map = h0.emptyMap();
|
|
}
|
|
ChannelMemberList channelMemberList = (ChannelMemberList) map.get(computeMemberListId);
|
|
return channelMemberList != null ? channelMemberList : new ChannelMemberList(computeMemberListId, this.getGuildMemberCount.invoke(Long.valueOf(j)).intValue(), AppLog.g);
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildMemberListUpdate(ModelGuildMemberListUpdate modelGuildMemberListUpdate) {
|
|
m.checkNotNullParameter(modelGuildMemberListUpdate, "update");
|
|
long guildId = modelGuildMemberListUpdate.getGuildId();
|
|
String id2 = modelGuildMemberListUpdate.getId();
|
|
MemberListUpdateLogger.INSTANCE.logUpdate(modelGuildMemberListUpdate);
|
|
try {
|
|
for (ModelGuildMemberListUpdate.Operation operation : modelGuildMemberListUpdate.getOperations()) {
|
|
if (operation instanceof ModelGuildMemberListUpdate.Operation.Sync) {
|
|
handleSync(id2, (ModelGuildMemberListUpdate.Operation.Sync) operation, guildId);
|
|
} else if (operation instanceof ModelGuildMemberListUpdate.Operation.Update) {
|
|
handleUpdate(id2, (ModelGuildMemberListUpdate.Operation.Update) operation, guildId);
|
|
} else if (operation instanceof ModelGuildMemberListUpdate.Operation.Insert) {
|
|
handleInsert(id2, (ModelGuildMemberListUpdate.Operation.Insert) operation, guildId);
|
|
} else if (operation instanceof ModelGuildMemberListUpdate.Operation.Delete) {
|
|
handleDelete(id2, (ModelGuildMemberListUpdate.Operation.Delete) operation, guildId);
|
|
} else if (operation instanceof ModelGuildMemberListUpdate.Operation.Invalidate) {
|
|
handleInvalidate(id2, (ModelGuildMemberListUpdate.Operation.Invalidate) operation, guildId);
|
|
}
|
|
}
|
|
ChannelMemberList memberList = getMemberList(modelGuildMemberListUpdate.getGuildId(), id2);
|
|
if (memberList != null) {
|
|
memberList.setGroups(modelGuildMemberListUpdate.getGroups(), new StoreChannelMembers$handleGuildMemberListUpdate$2(this, guildId));
|
|
}
|
|
} catch (Exception e) {
|
|
MemberListUpdateLogger.INSTANCE.dumpLogs(guildId, id2, e);
|
|
}
|
|
throttleMarkChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildRemove(long j) {
|
|
if (this.memberLists.remove(Long.valueOf(j)) != null) {
|
|
throttleMarkChanged();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildRoleCreateOrUpdate(long j) {
|
|
boolean allowOwnerIndicator = allowOwnerIndicator(j);
|
|
Map<String, ChannelMemberList> map = this.memberLists.get(Long.valueOf(j));
|
|
if (map != null) {
|
|
for (Map.Entry<String, ChannelMemberList> entry : map.entrySet()) {
|
|
entry.getValue().rebuildMembers(new StoreChannelMembers$handleGuildRoleCreateOrUpdate$$inlined$forEach$lambda$1(this, j, allowOwnerIndicator));
|
|
}
|
|
}
|
|
throttleMarkChanged();
|
|
}
|
|
|
|
public final Observable<ChannelMemberList> observeChannelMemberList(long j, long j2) {
|
|
Observable<ChannelMemberList> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChannelMembers$observeChannelMemberList$1(this, j, j2), 14, null).r();
|
|
m.checkNotNullExpressionValue(r, "observationDeck.connectR… .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
public void snapshotData() {
|
|
super.snapshotData();
|
|
Map<Long, Map<String, ChannelMemberList>> map = this.memberLists;
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap(g0.mapCapacity(map.size()));
|
|
Iterator<T> it = map.entrySet().iterator();
|
|
while (it.hasNext()) {
|
|
Map.Entry entry = (Map.Entry) it.next();
|
|
Object key = entry.getKey();
|
|
Map map2 = (Map) entry.getValue();
|
|
LinkedHashMap linkedHashMap2 = new LinkedHashMap(g0.mapCapacity(map2.size()));
|
|
for (Map.Entry entry2 : map2.entrySet()) {
|
|
linkedHashMap2.put(entry2.getKey(), new ChannelMemberList((ChannelMemberList) entry2.getValue()));
|
|
}
|
|
linkedHashMap.put(key, linkedHashMap2);
|
|
}
|
|
this.memberListsSnapshot = linkedHashMap;
|
|
}
|
|
}
|