677 lines
29 KiB
Java
677 lines
29 KiB
Java
package com.discord.stores;
|
|
|
|
import a0.a.a.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.activity.Activity;
|
|
import com.discord.api.activity.ActivityEmoji;
|
|
import com.discord.api.activity.ActivityType;
|
|
import com.discord.api.guild.Guild;
|
|
import com.discord.api.presence.ClientStatus;
|
|
import com.discord.api.presence.ClientStatuses;
|
|
import com.discord.api.thread.AugmentedThreadMember;
|
|
import com.discord.api.thread.ThreadListMember;
|
|
import com.discord.api.thread.ThreadMemberListUpdate;
|
|
import com.discord.api.thread.ThreadMembersUpdate;
|
|
import com.discord.api.user.User;
|
|
import com.discord.models.domain.ModelCustomStatusSetting;
|
|
import com.discord.models.domain.ModelPayload;
|
|
import com.discord.models.domain.ModelSession;
|
|
import com.discord.models.domain.ModelUserSettings;
|
|
import com.discord.models.domain.emoji.ModelEmojiCustom;
|
|
import com.discord.models.domain.emoji.ModelEmojiUnicode;
|
|
import com.discord.models.presence.Presence;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.utilities.collections.SnowflakePartitionMap;
|
|
import com.discord.utilities.presence.ActivityUtilsKt;
|
|
import com.discord.utilities.presence.PresenceUtils;
|
|
import com.discord.utilities.time.Clock;
|
|
import com.discord.utilities.time.TimeUtils;
|
|
import d0.t.u;
|
|
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: StoreUserPresence.kt */
|
|
public final class StoreUserPresence extends StoreV2 {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final StoreUserPresence$Companion$LocalPresenceUpdateSource$1 LocalPresenceUpdateSource = new StoreUserPresence$Companion$LocalPresenceUpdateSource$1();
|
|
private final Clock clock;
|
|
private Presence localPresence;
|
|
private Presence localPresenceSnapshot;
|
|
private MeUser meUser;
|
|
private final ObservationDeck observationDeck;
|
|
private final SnowflakePartitionMap.CopiablePartitionMap<Presence> presences = new SnowflakePartitionMap.CopiablePartitionMap<>(0, 1, null);
|
|
private Map<Long, Presence> presencesSnapshot = new HashMap();
|
|
private final StoreStream stream;
|
|
private final HashMap<Long, Map<Long, TimestampedPresence>> userGuildPresences = new HashMap<>();
|
|
|
|
/* compiled from: StoreUserPresence.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreUserPresence.kt */
|
|
public static final class TimestampedPresence {
|
|
private final Presence presence;
|
|
private final long timestamp;
|
|
|
|
public TimestampedPresence(Presence presence, long j) {
|
|
m.checkNotNullParameter(presence, "presence");
|
|
this.presence = presence;
|
|
this.timestamp = j;
|
|
}
|
|
|
|
public static /* synthetic */ TimestampedPresence copy$default(TimestampedPresence timestampedPresence, Presence presence, long j, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
presence = timestampedPresence.presence;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
j = timestampedPresence.timestamp;
|
|
}
|
|
return timestampedPresence.copy(presence, j);
|
|
}
|
|
|
|
public final Presence component1() {
|
|
return this.presence;
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.timestamp;
|
|
}
|
|
|
|
public final TimestampedPresence copy(Presence presence, long j) {
|
|
m.checkNotNullParameter(presence, "presence");
|
|
return new TimestampedPresence(presence, j);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof TimestampedPresence)) {
|
|
return false;
|
|
}
|
|
TimestampedPresence timestampedPresence = (TimestampedPresence) obj;
|
|
return m.areEqual(this.presence, timestampedPresence.presence) && this.timestamp == timestampedPresence.timestamp;
|
|
}
|
|
|
|
public final Presence getPresence() {
|
|
return this.presence;
|
|
}
|
|
|
|
public final long getTimestamp() {
|
|
return this.timestamp;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Presence presence = this.presence;
|
|
return b.a(this.timestamp) + ((presence != null ? presence.hashCode() : 0) * 31);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("TimestampedPresence(presence=");
|
|
L.append(this.presence);
|
|
L.append(", timestamp=");
|
|
return a.z(L, this.timestamp, ")");
|
|
}
|
|
}
|
|
|
|
public StoreUserPresence(Clock clock, StoreStream storeStream, ObservationDeck observationDeck) {
|
|
m.checkNotNullParameter(clock, "clock");
|
|
m.checkNotNullParameter(storeStream, "stream");
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
this.clock = clock;
|
|
this.stream = storeStream;
|
|
this.observationDeck = observationDeck;
|
|
ClientStatus clientStatus = ClientStatus.ONLINE;
|
|
ClientStatus clientStatus2 = ClientStatus.OFFLINE;
|
|
Presence presence = new Presence(clientStatus, new ClientStatuses(clientStatus2, clientStatus2, clientStatus), null);
|
|
this.localPresence = presence;
|
|
this.localPresenceSnapshot = Presence.copy$default(presence, null, null, null, 7, null);
|
|
}
|
|
|
|
public static final /* synthetic */ Presence access$getLocalPresenceSnapshot$p(StoreUserPresence storeUserPresence) {
|
|
return storeUserPresence.localPresenceSnapshot;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setLocalPresenceSnapshot$p(StoreUserPresence storeUserPresence, Presence presence) {
|
|
storeUserPresence.localPresenceSnapshot = presence;
|
|
}
|
|
|
|
@StoreThread
|
|
private final void clearPresences(long j) {
|
|
HashMap<Long, Map<Long, TimestampedPresence>> hashMap = this.userGuildPresences;
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
for (Map.Entry<Long, Map<Long, TimestampedPresence>> entry : hashMap.entrySet()) {
|
|
if (entry.getValue().remove(Long.valueOf(j)) != null) {
|
|
linkedHashMap.put(entry.getKey(), entry.getValue());
|
|
}
|
|
}
|
|
for (Map.Entry entry2 : linkedHashMap.entrySet()) {
|
|
flattenPresence(((Number) entry2.getKey()).longValue());
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:31:0x007b */
|
|
/* JADX WARNING: Removed duplicated region for block: B:32:0x0080 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:35:0x0085 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:38:0x009e */
|
|
@StoreThread
|
|
private final void flattenPresence(long j) {
|
|
Presence presence;
|
|
ClientStatus clientStatus;
|
|
ClientStatus clientStatus2;
|
|
List<Activity> activities;
|
|
List sortedWith;
|
|
Collection<TimestampedPresence> values;
|
|
Object obj;
|
|
Map<Long, TimestampedPresence> map = this.userGuildPresences.get(Long.valueOf(j));
|
|
ClientStatus clientStatus3 = null;
|
|
if (!(map == null || (values = map.values()) == null)) {
|
|
Iterator<T> it = values.iterator();
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
} else {
|
|
obj = it.next();
|
|
if (it.hasNext()) {
|
|
long timestamp = ((TimestampedPresence) obj).getTimestamp();
|
|
do {
|
|
Object next = it.next();
|
|
long timestamp2 = ((TimestampedPresence) next).getTimestamp();
|
|
if (timestamp < timestamp2) {
|
|
obj = next;
|
|
timestamp = timestamp2;
|
|
}
|
|
} while (it.hasNext());
|
|
}
|
|
}
|
|
TimestampedPresence timestampedPresence = (TimestampedPresence) obj;
|
|
if (timestampedPresence != null) {
|
|
presence = timestampedPresence.getPresence();
|
|
if (presence == null || (clientStatus = presence.getStatus()) == null) {
|
|
clientStatus = ClientStatus.OFFLINE;
|
|
}
|
|
List reversed = (presence != null || (activities = presence.getActivities()) == null || (sortedWith = u.sortedWith(activities, PresenceUtils.INSTANCE.getACTIVITY_COMPARATOR$app_productionBetaRelease())) == null) ? null : u.reversed(sortedWith);
|
|
ClientStatuses clientStatuses = presence == null ? presence.getClientStatuses() : null;
|
|
clientStatus2 = ClientStatus.OFFLINE;
|
|
if (clientStatus != clientStatus2) {
|
|
this.userGuildPresences.remove(Long.valueOf(j));
|
|
if (this.presences.remove(Long.valueOf(j)) != null) {
|
|
markChanged();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
Presence presence2 = this.presences.get(Long.valueOf(j));
|
|
if (presence2 != null) {
|
|
clientStatus3 = presence2.getStatus();
|
|
}
|
|
if (clientStatus3 != clientStatus || (!m.areEqual(presence2.getActivities(), reversed)) || (!m.areEqual(presence2.getClientStatuses(), clientStatuses))) {
|
|
SnowflakePartitionMap.CopiablePartitionMap<Presence> copiablePartitionMap = this.presences;
|
|
Long valueOf = Long.valueOf(j);
|
|
if (clientStatuses == null) {
|
|
clientStatuses = new ClientStatuses(clientStatus2, clientStatus2, clientStatus2);
|
|
}
|
|
copiablePartitionMap.put(valueOf, new Presence(clientStatus, clientStatuses, reversed));
|
|
markChanged();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
presence = null;
|
|
clientStatus = ClientStatus.OFFLINE;
|
|
if (presence != null) {
|
|
}
|
|
if (presence == null) {
|
|
}
|
|
clientStatus2 = ClientStatus.OFFLINE;
|
|
if (clientStatus != clientStatus2) {
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
private final Activity getCustomStatusActivityFromSetting(ModelCustomStatusSetting modelCustomStatusSetting) {
|
|
ActivityEmoji activityEmoji = null;
|
|
if (modelCustomStatusSetting == ModelCustomStatusSetting.Companion.getCLEAR()) {
|
|
return null;
|
|
}
|
|
if (modelCustomStatusSetting.getExpiresAt() != null && TimeUtils.parseUTCDate(modelCustomStatusSetting.getExpiresAt()) - this.clock.currentTimeMillis() <= 0) {
|
|
return null;
|
|
}
|
|
if (modelCustomStatusSetting.getEmojiId() != null) {
|
|
StoreEmoji emojis$app_productionBetaRelease = this.stream.getEmojis$app_productionBetaRelease();
|
|
Long emojiId = modelCustomStatusSetting.getEmojiId();
|
|
m.checkNotNull(emojiId);
|
|
ModelEmojiCustom customEmojiInternal = emojis$app_productionBetaRelease.getCustomEmojiInternal(emojiId.longValue());
|
|
if (customEmojiInternal != null) {
|
|
activityEmoji = new ActivityEmoji(String.valueOf(customEmojiInternal.getId()), customEmojiInternal.getName(), customEmojiInternal.isAnimated());
|
|
}
|
|
} else if (modelCustomStatusSetting.getEmojiName() != null) {
|
|
Map<String, ModelEmojiUnicode> unicodeEmojiSurrogateMap = this.stream.getEmojis$app_productionBetaRelease().getUnicodeEmojiSurrogateMap();
|
|
String emojiName = modelCustomStatusSetting.getEmojiName();
|
|
m.checkNotNull(emojiName);
|
|
ModelEmojiUnicode modelEmojiUnicode = unicodeEmojiSurrogateMap.get(emojiName);
|
|
if (modelEmojiUnicode != null) {
|
|
activityEmoji = new ActivityEmoji(null, modelEmojiUnicode.getSurrogates(), false);
|
|
}
|
|
}
|
|
return ActivityUtilsKt.createCustomStatusActivity(modelCustomStatusSetting.getText(), activityEmoji, this.clock.currentTimeMillis());
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:17:0x0035 */
|
|
private final List<Activity> removeActivityInList(ActivityType activityType, List<Activity> list) {
|
|
List<Activity> list2;
|
|
int i;
|
|
if (list == null || (list2 = u.toMutableList((Collection) list)) == null) {
|
|
list2 = new ArrayList<>();
|
|
}
|
|
if (list != null) {
|
|
Iterator<Activity> it = list.iterator();
|
|
i = 0;
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
if (it.next().p() == activityType) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
if (i != -1) {
|
|
list2.remove(i);
|
|
}
|
|
return list2;
|
|
}
|
|
i = -1;
|
|
if (i != -1) {
|
|
}
|
|
return list2;
|
|
}
|
|
|
|
private final List<Activity> replaceActivityInList(Activity activity, List<Activity> list) {
|
|
List<Activity> removeActivityInList = removeActivityInList(activity.p(), list);
|
|
removeActivityInList.add(activity);
|
|
return removeActivityInList;
|
|
}
|
|
|
|
public static /* synthetic */ void updateActivity$default(StoreUserPresence storeUserPresence, ActivityType activityType, Activity activity, boolean z2, int i, Object obj) {
|
|
if ((i & 4) != 0) {
|
|
z2 = false;
|
|
}
|
|
storeUserPresence.updateActivity(activityType, activity, z2);
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:18:0x0042, code lost:
|
|
if (r11 != null) goto L_0x0057;
|
|
*/
|
|
/* JADX WARNING: Removed duplicated region for block: B:25:0x005c */
|
|
/* JADX WARNING: Removed duplicated region for block: B:26:0x0061 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:28:0x0064 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:32:0x0082 */
|
|
@StoreThread
|
|
private final void updateSelfPresence(ModelUserSettings modelUserSettings, List<? extends ModelSession> list, boolean z2) {
|
|
ClientStatus clientStatus;
|
|
List<Activity> list2;
|
|
ModelCustomStatusSetting customStatus;
|
|
List<Activity> list3;
|
|
List<Activity> list4;
|
|
Object obj;
|
|
MeUser meUser = this.meUser;
|
|
if (meUser != null) {
|
|
long id2 = meUser.getId();
|
|
if (modelUserSettings == null || (clientStatus = modelUserSettings.getStatus()) == null) {
|
|
clientStatus = this.localPresence.getStatus();
|
|
}
|
|
m.checkNotNullExpressionValue(clientStatus, "userSettings?.status\n … ?: localPresence.status");
|
|
if (list != null) {
|
|
Iterator<T> it = list.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (((ModelSession) obj).isActive()) {
|
|
break;
|
|
}
|
|
}
|
|
ModelSession modelSession = (ModelSession) obj;
|
|
if (modelSession != null) {
|
|
list4 = modelSession.getActivities();
|
|
}
|
|
}
|
|
Presence presence = this.presences.get(Long.valueOf(id2));
|
|
if (presence != null) {
|
|
list4 = presence.getActivities();
|
|
list2 = list4;
|
|
customStatus = modelUserSettings == null ? modelUserSettings.getCustomStatus() : null;
|
|
if (customStatus == null) {
|
|
Activity customStatusActivityFromSetting = getCustomStatusActivityFromSetting(customStatus);
|
|
list3 = customStatusActivityFromSetting != null ? replaceActivityInList(customStatusActivityFromSetting, this.localPresence.getActivities()) : removeActivityInList(ActivityType.CUSTOM_STATUS, this.localPresence.getActivities());
|
|
} else {
|
|
list3 = this.localPresence.getActivities();
|
|
}
|
|
if (clientStatus != this.localPresence.getStatus() || (!m.areEqual(list3, this.localPresence.getActivities()))) {
|
|
this.localPresence = new Presence(clientStatus, null, list3);
|
|
markChanged(LocalPresenceUpdateSource);
|
|
}
|
|
handlePresenceUpdate(Long.MAX_VALUE, id2, clientStatus, null, list2);
|
|
if (!z2 && PresenceUtils.INSTANCE.getCustomStatusActivity(this.localPresence) == null) {
|
|
markUnchanged(LocalPresenceUpdateSource);
|
|
return;
|
|
}
|
|
}
|
|
list2 = null;
|
|
if (modelUserSettings == null) {
|
|
}
|
|
if (customStatus == null) {
|
|
}
|
|
this.localPresence = new Presence(clientStatus, null, list3);
|
|
markChanged(LocalPresenceUpdateSource);
|
|
handlePresenceUpdate(Long.MAX_VALUE, id2, clientStatus, null, list2);
|
|
if (!z2) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public final Activity getApplicationActivity(long j, long j2) {
|
|
List<Activity> activities;
|
|
boolean z2;
|
|
Presence presence = this.presencesSnapshot.get(Long.valueOf(j));
|
|
Object obj = null;
|
|
if (presence == null || (activities = presence.getActivities()) == null) {
|
|
return null;
|
|
}
|
|
Iterator<T> it = activities.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
Object next = it.next();
|
|
Long a = ((Activity) next).a();
|
|
if (a != null && a.longValue() == j2) {
|
|
z2 = true;
|
|
continue;
|
|
} else {
|
|
z2 = false;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
obj = next;
|
|
break;
|
|
}
|
|
}
|
|
return (Activity) obj;
|
|
}
|
|
|
|
public final Presence getLocalPresence$app_productionBetaRelease() {
|
|
return this.localPresence;
|
|
}
|
|
|
|
public final ObservationDeck getObservationDeck() {
|
|
return this.observationDeck;
|
|
}
|
|
|
|
public final SnowflakePartitionMap.CopiablePartitionMap<Presence> getPresences() {
|
|
return this.presences;
|
|
}
|
|
|
|
/* renamed from: getPresences reason: collision with other method in class */
|
|
public final Map<Long, Presence> m14getPresences() {
|
|
return this.presencesSnapshot;
|
|
}
|
|
|
|
public final StoreStream getStream() {
|
|
return this.stream;
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleConnectionOpen(ModelPayload modelPayload) {
|
|
m.checkNotNullParameter(modelPayload, "payload");
|
|
this.userGuildPresences.clear();
|
|
this.presences.clear();
|
|
User me2 = modelPayload.getMe();
|
|
m.checkNotNullExpressionValue(me2, "payload.me");
|
|
this.meUser = new MeUser(me2);
|
|
List<Guild> guilds = modelPayload.getGuilds();
|
|
m.checkNotNullExpressionValue(guilds, "payload.guilds");
|
|
for (Guild guild : guilds) {
|
|
handleGuildAdd(guild);
|
|
}
|
|
List<com.discord.api.presence.Presence> presences = modelPayload.getPresences();
|
|
m.checkNotNullExpressionValue(presences, "payload.presences");
|
|
for (com.discord.api.presence.Presence presence : presences) {
|
|
User f = presence.f();
|
|
if (f != null) {
|
|
handlePresenceUpdate(Long.MAX_VALUE, f.i(), presence.e(), presence.c(), presence.b());
|
|
}
|
|
}
|
|
updateSelfPresence(modelPayload.getUserSettings(), modelPayload.getSessions(), false);
|
|
markChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildAdd(Guild guild) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
List<com.discord.api.presence.Presence> A = guild.A();
|
|
if (A != null) {
|
|
for (com.discord.api.presence.Presence presence : A) {
|
|
User f = presence.f();
|
|
if (f != null) {
|
|
handlePresenceUpdate(guild.o(), f.i(), presence.e(), presence.c(), presence.b());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildMemberRemove(long j, long j2) {
|
|
Map<Long, TimestampedPresence> map = this.userGuildPresences.get(Long.valueOf(j2));
|
|
if ((map != null ? map.remove(Long.valueOf(j)) : null) != null) {
|
|
flattenPresence(j2);
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleGuildRemove(Guild guild) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
clearPresences(guild.o());
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handlePresenceReplace(List<com.discord.api.presence.Presence> list) {
|
|
m.checkNotNullParameter(list, "presencesList");
|
|
clearPresences(Long.MAX_VALUE);
|
|
for (com.discord.api.presence.Presence presence : list) {
|
|
User f = presence.f();
|
|
if (f != null) {
|
|
long i = f.i();
|
|
ClientStatus e = presence.e();
|
|
ClientStatuses c2 = presence.c();
|
|
if (c2 == null) {
|
|
ClientStatus clientStatus = ClientStatus.OFFLINE;
|
|
c2 = new ClientStatuses(clientStatus, clientStatus, clientStatus);
|
|
}
|
|
handlePresenceUpdate(Long.MAX_VALUE, i, e, c2, presence.b());
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handlePresenceUpdate(long j, long j2, ClientStatus clientStatus, ClientStatuses clientStatuses, List<Activity> list) {
|
|
m.checkNotNullParameter(clientStatus, "status");
|
|
if (j == 0) {
|
|
j = Long.MAX_VALUE;
|
|
}
|
|
MeUser meUser = this.meUser;
|
|
if (meUser == null || meUser.getId() != j2 || j == Long.MAX_VALUE) {
|
|
HashMap<Long, Map<Long, TimestampedPresence>> hashMap = this.userGuildPresences;
|
|
Long valueOf = Long.valueOf(j2);
|
|
Map<Long, TimestampedPresence> map = hashMap.get(valueOf);
|
|
if (map == null) {
|
|
map = new HashMap<>();
|
|
hashMap.put(valueOf, map);
|
|
}
|
|
map.put(Long.valueOf(j), new TimestampedPresence(new Presence(clientStatus, clientStatuses, list), this.clock.currentTimeMillis()));
|
|
flattenPresence(j2);
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handlePresenceUpdate(long j, com.discord.api.presence.Presence presence) {
|
|
m.checkNotNullParameter(presence, "presence");
|
|
User f = presence.f();
|
|
if (f != null) {
|
|
handlePresenceUpdate(j, f.i(), presence.e(), presence.c(), presence.b());
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleSessionsReplace(List<? extends ModelSession> list) {
|
|
m.checkNotNullParameter(list, "sessions");
|
|
updateSelfPresence(null, list, true);
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleThreadMemberListUpdate(ThreadMemberListUpdate threadMemberListUpdate) {
|
|
m.checkNotNullParameter(threadMemberListUpdate, "threadMemberListUpdate");
|
|
List<ThreadListMember> b = threadMemberListUpdate.b();
|
|
if (b != null) {
|
|
for (ThreadListMember threadListMember : b) {
|
|
com.discord.api.presence.Presence b2 = threadListMember.b();
|
|
if (b2 != null) {
|
|
handlePresenceUpdate(threadMemberListUpdate.a(), threadListMember.c(), b2.e(), b2.c(), b2.b());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleThreadMembersUpdate(ThreadMembersUpdate threadMembersUpdate) {
|
|
m.checkNotNullParameter(threadMembersUpdate, "threadMembersUpdate");
|
|
List<AugmentedThreadMember> a = threadMembersUpdate.a();
|
|
if (a != null) {
|
|
for (AugmentedThreadMember augmentedThreadMember : a) {
|
|
com.discord.api.presence.Presence d = augmentedThreadMember.d();
|
|
if (d != null) {
|
|
handlePresenceUpdate(threadMembersUpdate.b(), augmentedThreadMember.e(), d.e(), d.c(), d.b());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleUserSettingsUpdate(ModelUserSettings modelUserSettings) {
|
|
m.checkNotNullParameter(modelUserSettings, "userSettings");
|
|
updateSelfPresence(modelUserSettings, null, true);
|
|
}
|
|
|
|
public final Observable<Map<Long, Presence>> observeAllPresences() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreUserPresence$observeAllPresences$1(this), 14, null);
|
|
}
|
|
|
|
public final Observable<Activity> observeApplicationActivity(long j, long j2) {
|
|
Observable<Activity> r = observePresenceForUser(j).F(new StoreUserPresence$observeApplicationActivity$1(j2)).r();
|
|
m.checkNotNullExpressionValue(r, "observePresenceForUser(u… .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
public final Observable<Presence> observeLocalPresence() {
|
|
Observable<Presence> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{LocalPresenceUpdateSource}, false, null, null, new StoreUserPresence$observeLocalPresence$1(this), 14, null).r();
|
|
m.checkNotNullExpressionValue(r, "observationDeck\n .c… .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
public final Observable<Presence> observePresenceForUser(long j) {
|
|
Observable<Presence> r = observeAllPresences().F(new StoreUserPresence$observePresenceForUser$1(j)).r();
|
|
m.checkNotNullExpressionValue(r, "observeAllPresences()\n … .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
public final Observable<Map<Long, Presence>> observePresencesForUsers(Collection<Long> collection) {
|
|
m.checkNotNullParameter(collection, "userIds");
|
|
Observable<Map<Long, Presence>> r = observeAllPresences().F(new StoreUserPresence$observePresencesForUsers$1(collection)).r();
|
|
m.checkNotNullExpressionValue(r, "observeAllPresences()\n … .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreV2
|
|
@StoreThread
|
|
public void snapshotData() {
|
|
this.presencesSnapshot = this.presences.fastCopy();
|
|
Presence presence = this.localPresence;
|
|
List<Activity> activities = presence.getActivities();
|
|
this.localPresenceSnapshot = Presence.copy$default(presence, null, null, activities != null ? u.toList(activities) : null, 3, null);
|
|
if (getUpdateSources().contains(LocalPresenceUpdateSource)) {
|
|
StoreGatewayConnection.presenceUpdate$default(StoreStream.Companion.getGatewaySocket(), this.localPresence.getStatus(), null, this.localPresence.getActivities(), null, 10, null);
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void updateActivity(ActivityType activityType, Activity activity, boolean z2) {
|
|
Activity activity2;
|
|
Object obj;
|
|
boolean z3;
|
|
m.checkNotNullParameter(activityType, "type");
|
|
if (!z2) {
|
|
List<Activity> activities = this.localPresence.getActivities();
|
|
if (activities != null) {
|
|
Iterator<T> it = activities.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (((Activity) obj).p() == (activity != null ? activity.p() : null)) {
|
|
z3 = true;
|
|
continue;
|
|
} else {
|
|
z3 = false;
|
|
continue;
|
|
}
|
|
if (z3) {
|
|
break;
|
|
}
|
|
}
|
|
activity2 = (Activity) obj;
|
|
} else {
|
|
activity2 = null;
|
|
}
|
|
if (!(!m.areEqual(activity, activity2))) {
|
|
return;
|
|
}
|
|
}
|
|
List<Activity> replaceActivityInList = activity != null ? replaceActivityInList(activity, this.localPresence.getActivities()) : removeActivityInList(activityType, this.localPresence.getActivities());
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Object obj2 : replaceActivityInList) {
|
|
if (((Activity) obj2).p() != ActivityType.UNKNOWN) {
|
|
arrayList.add(obj2);
|
|
}
|
|
}
|
|
this.localPresence = new Presence(this.localPresence.getStatus(), null, arrayList);
|
|
markChanged(LocalPresenceUpdateSource);
|
|
MeUser meUser = this.meUser;
|
|
if (meUser != null) {
|
|
long id2 = meUser.getId();
|
|
if (!m.areEqual(this.presences.get(Long.valueOf(id2)), this.localPresence)) {
|
|
this.presences.put(Long.valueOf(id2), this.localPresence);
|
|
markChanged();
|
|
}
|
|
}
|
|
}
|
|
}
|