664 lines
28 KiB
Java
664 lines
28 KiB
Java
|
package com.discord.stores;
|
||
|
|
||
|
import a0.a.a.b;
|
||
|
import android.content.Context;
|
||
|
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.guildmember.GuildMember;
|
||
|
import com.discord.api.utcdatetime.UtcDateTime;
|
||
|
import com.discord.models.domain.ModelMessage;
|
||
|
import com.discord.models.domain.ModelPayload;
|
||
|
import com.discord.models.domain.ModelReadState;
|
||
|
import com.discord.stores.StoreThreadsActiveJoined;
|
||
|
import com.discord.stores.updates.ObservationDeck;
|
||
|
import com.discord.utilities.persister.Persister;
|
||
|
import com.discord.utilities.rest.RestAPI;
|
||
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
||
|
import com.discord.utilities.threads.ThreadUtils;
|
||
|
import d0.o;
|
||
|
import d0.t.n0;
|
||
|
import d0.t.o0;
|
||
|
import d0.z.d.m;
|
||
|
import j0.l.e.j;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.HashMap;
|
||
|
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.NoWhenBranchMatchedException;
|
||
|
import kotlin.Pair;
|
||
|
import kotlin.Unit;
|
||
|
import kotlin.jvm.functions.Function0;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
import rx.Observable;
|
||
|
import rx.Subscription;
|
||
|
/* compiled from: StoreMessageAck.kt */
|
||
|
public final class StoreMessageAck extends StoreV2 {
|
||
|
private final Map<Long, Ack> acks = new HashMap(this.acksSnapshot);
|
||
|
private final Persister<Map<Long, Ack>> acksPersister;
|
||
|
private Map<Long, Ack> acksSnapshot;
|
||
|
private final Dispatcher dispatcher;
|
||
|
private final ObservationDeck observationDeck;
|
||
|
private final RestAPI restAPI;
|
||
|
private final StoreStream stream;
|
||
|
private Subscription threadSyncSubscription;
|
||
|
|
||
|
/* compiled from: StoreMessageAck.kt */
|
||
|
public static final class Ack {
|
||
|
private final boolean isLockedAck;
|
||
|
private final long messageId;
|
||
|
private final boolean viewed;
|
||
|
|
||
|
public Ack(long j, boolean z2, boolean z3) {
|
||
|
this.messageId = j;
|
||
|
this.viewed = z2;
|
||
|
this.isLockedAck = z3;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
||
|
public Ack(ModelReadState modelReadState, boolean z2, boolean z3) {
|
||
|
this(modelReadState != null ? modelReadState.getLastMessageId() : 0, z2, z3);
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ Ack copy$default(Ack ack, long j, boolean z2, boolean z3, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
j = ack.messageId;
|
||
|
}
|
||
|
if ((i & 2) != 0) {
|
||
|
z2 = ack.viewed;
|
||
|
}
|
||
|
if ((i & 4) != 0) {
|
||
|
z3 = ack.isLockedAck;
|
||
|
}
|
||
|
return ack.copy(j, z2, z3);
|
||
|
}
|
||
|
|
||
|
public final long component1() {
|
||
|
return this.messageId;
|
||
|
}
|
||
|
|
||
|
public final boolean component2() {
|
||
|
return this.viewed;
|
||
|
}
|
||
|
|
||
|
public final boolean component3() {
|
||
|
return this.isLockedAck;
|
||
|
}
|
||
|
|
||
|
public final Ack copy(long j, boolean z2, boolean z3) {
|
||
|
return new Ack(j, z2, z3);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this == obj) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!(obj instanceof Ack)) {
|
||
|
return false;
|
||
|
}
|
||
|
Ack ack = (Ack) obj;
|
||
|
return this.messageId == ack.messageId && this.viewed == ack.viewed && this.isLockedAck == ack.isLockedAck;
|
||
|
}
|
||
|
|
||
|
public final long getMessageId() {
|
||
|
return this.messageId;
|
||
|
}
|
||
|
|
||
|
public final boolean getViewed() {
|
||
|
return this.viewed;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
int a = b.a(this.messageId) * 31;
|
||
|
boolean z2 = this.viewed;
|
||
|
int i = 1;
|
||
|
if (z2) {
|
||
|
z2 = true;
|
||
|
}
|
||
|
int i2 = z2 ? 1 : 0;
|
||
|
int i3 = z2 ? 1 : 0;
|
||
|
int i4 = z2 ? 1 : 0;
|
||
|
int i5 = (a + i2) * 31;
|
||
|
boolean z3 = this.isLockedAck;
|
||
|
if (!z3) {
|
||
|
i = z3 ? 1 : 0;
|
||
|
}
|
||
|
return i5 + i;
|
||
|
}
|
||
|
|
||
|
public final boolean isLockedAck() {
|
||
|
return this.isLockedAck;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder L = a.L("Ack(messageId=");
|
||
|
L.append(this.messageId);
|
||
|
L.append(", viewed=");
|
||
|
L.append(this.viewed);
|
||
|
L.append(", isLockedAck=");
|
||
|
return a.G(L, this.isLockedAck, ")");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: StoreMessageAck.kt */
|
||
|
public static final class PendingAck {
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
private static final PendingAck EMPTY = new PendingAck(0, new Ack(0L, false, false));
|
||
|
private final Ack ack;
|
||
|
private final long channelId;
|
||
|
|
||
|
/* compiled from: StoreMessageAck.kt */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
|
||
|
public final PendingAck getEMPTY() {
|
||
|
return PendingAck.access$getEMPTY$cp();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public PendingAck(long j, Ack ack) {
|
||
|
m.checkNotNullParameter(ack, "ack");
|
||
|
this.channelId = j;
|
||
|
this.ack = ack;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ PendingAck access$getEMPTY$cp() {
|
||
|
return EMPTY;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ PendingAck copy$default(PendingAck pendingAck, long j, Ack ack, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
j = pendingAck.channelId;
|
||
|
}
|
||
|
if ((i & 2) != 0) {
|
||
|
ack = pendingAck.ack;
|
||
|
}
|
||
|
return pendingAck.copy(j, ack);
|
||
|
}
|
||
|
|
||
|
public final long component1() {
|
||
|
return this.channelId;
|
||
|
}
|
||
|
|
||
|
public final Ack component2() {
|
||
|
return this.ack;
|
||
|
}
|
||
|
|
||
|
public final PendingAck copy(long j, Ack ack) {
|
||
|
m.checkNotNullParameter(ack, "ack");
|
||
|
return new PendingAck(j, ack);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this == obj) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!(obj instanceof PendingAck)) {
|
||
|
return false;
|
||
|
}
|
||
|
PendingAck pendingAck = (PendingAck) obj;
|
||
|
return this.channelId == pendingAck.channelId && m.areEqual(this.ack, pendingAck.ack);
|
||
|
}
|
||
|
|
||
|
public final Ack getAck() {
|
||
|
return this.ack;
|
||
|
}
|
||
|
|
||
|
public final long getChannelId() {
|
||
|
return this.channelId;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
int a = b.a(this.channelId) * 31;
|
||
|
Ack ack = this.ack;
|
||
|
return a + (ack != null ? ack.hashCode() : 0);
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder L = a.L("PendingAck(channelId=");
|
||
|
L.append(this.channelId);
|
||
|
L.append(", ack=");
|
||
|
L.append(this.ack);
|
||
|
L.append(")");
|
||
|
return L.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: StoreMessageAck.kt */
|
||
|
public static abstract class ThreadState {
|
||
|
|
||
|
/* compiled from: StoreMessageAck.kt */
|
||
|
public static final class NotThread extends ThreadState {
|
||
|
public static final NotThread INSTANCE = new NotThread();
|
||
|
|
||
|
private NotThread() {
|
||
|
super(null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: StoreMessageAck.kt */
|
||
|
public static final class Thread extends ThreadState {
|
||
|
private final boolean isActiveJoined;
|
||
|
|
||
|
public Thread(boolean z2) {
|
||
|
super(null);
|
||
|
this.isActiveJoined = z2;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ Thread copy$default(Thread thread, boolean z2, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
z2 = thread.isActiveJoined;
|
||
|
}
|
||
|
return thread.copy(z2);
|
||
|
}
|
||
|
|
||
|
public final boolean component1() {
|
||
|
return this.isActiveJoined;
|
||
|
}
|
||
|
|
||
|
public final Thread copy(boolean z2) {
|
||
|
return new Thread(z2);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this != obj) {
|
||
|
return (obj instanceof Thread) && this.isActiveJoined == ((Thread) obj).isActiveJoined;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
boolean z2 = this.isActiveJoined;
|
||
|
if (z2) {
|
||
|
return 1;
|
||
|
}
|
||
|
return z2 ? 1 : 0;
|
||
|
}
|
||
|
|
||
|
public final boolean isActiveJoined() {
|
||
|
return this.isActiveJoined;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
return a.G(a.L("Thread(isActiveJoined="), this.isActiveJoined, ")");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private ThreadState() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ ThreadState(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public StoreMessageAck(StoreStream storeStream, ObservationDeck observationDeck, Dispatcher dispatcher, RestAPI restAPI) {
|
||
|
m.checkNotNullParameter(storeStream, "stream");
|
||
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
||
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
||
|
m.checkNotNullParameter(restAPI, "restAPI");
|
||
|
this.stream = storeStream;
|
||
|
this.observationDeck = observationDeck;
|
||
|
this.dispatcher = dispatcher;
|
||
|
this.restAPI = restAPI;
|
||
|
Persister<Map<Long, Ack>> persister = new Persister<>("MOST_RECENT_ACKS_V3", new HashMap());
|
||
|
this.acksPersister = persister;
|
||
|
this.acksSnapshot = persister.get();
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreMessageAck storeMessageAck) {
|
||
|
return storeMessageAck.dispatcher;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ RestAPI access$getRestAPI$p(StoreMessageAck storeMessageAck) {
|
||
|
return storeMessageAck.restAPI;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ StoreStream access$getStream$p(StoreMessageAck storeMessageAck) {
|
||
|
return storeMessageAck.stream;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Subscription access$getThreadSyncSubscription$p(StoreMessageAck storeMessageAck) {
|
||
|
return storeMessageAck.threadSyncSubscription;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$internalAck(StoreMessageAck storeMessageAck, Channel channel, boolean z2, boolean z3) {
|
||
|
storeMessageAck.internalAck(channel, z2, z3);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Observable access$observeThreadState(StoreMessageAck storeMessageAck, long j) {
|
||
|
return storeMessageAck.observeThreadState(j);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$postPendingAck(StoreMessageAck storeMessageAck, Observable observable, int i) {
|
||
|
storeMessageAck.postPendingAck(observable, i);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$setThreadSyncSubscription$p(StoreMessageAck storeMessageAck, Subscription subscription) {
|
||
|
storeMessageAck.threadSyncSubscription = subscription;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ boolean access$shouldAck(StoreMessageAck storeMessageAck, ThreadState threadState) {
|
||
|
return storeMessageAck.shouldAck(threadState);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$updateAcks(StoreMessageAck storeMessageAck, long j, Ack ack) {
|
||
|
storeMessageAck.updateAcks(j, ack);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$updateThreadAcks(StoreMessageAck storeMessageAck, Set set, Set set2) {
|
||
|
storeMessageAck.updateThreadAcks(set, set2);
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ void ack$default(StoreMessageAck storeMessageAck, long j, boolean z2, boolean z3, int i, Object obj) {
|
||
|
if ((i & 4) != 0) {
|
||
|
z3 = false;
|
||
|
}
|
||
|
storeMessageAck.ack(j, z2, z3);
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.stores.StoreMessageAck */
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static /* synthetic */ void ackGuild$default(StoreMessageAck storeMessageAck, Context context, long j, Function0 function0, int i, Object obj) {
|
||
|
if ((i & 4) != 0) {
|
||
|
function0 = StoreMessageAck$ackGuild$1.INSTANCE;
|
||
|
}
|
||
|
storeMessageAck.ackGuild(context, j, function0);
|
||
|
}
|
||
|
|
||
|
private final Observable<PendingAck> getPendingAck(Observable<Long> observable, boolean z2, boolean z3) {
|
||
|
Observable<R> Z = observable.Z(new StoreMessageAck$getPendingAck$2(this, z2, new StoreMessageAck$getPendingAck$1(z3)));
|
||
|
m.checkNotNullExpressionValue(Z, "switchMap { channelId ->…gAck.EMPTY)\n }\n }");
|
||
|
return Z;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final ThreadState getThreadStateInternal(long j) {
|
||
|
return !this.stream.getChannels$app_productionBetaRelease().getThreadsByIdInternal$app_productionBetaRelease().containsKey(Long.valueOf(j)) ? ThreadState.NotThread.INSTANCE : new ThreadState.Thread(this.stream.getThreadsActiveJoined$app_productionBetaRelease().getActiveJoinedThreadsInternal$app_productionBetaRelease().containsKey(Long.valueOf(j)));
|
||
|
}
|
||
|
|
||
|
private final void internalAck(Channel channel, boolean z2, boolean z3) {
|
||
|
j jVar = new j(Long.valueOf(channel.g()));
|
||
|
m.checkNotNullExpressionValue(jVar, "Observable.just(channel.id)");
|
||
|
postPendingAck$default(this, ObservableExtensionsKt.takeSingleUntilTimeout$default(getPendingAck(jVar, z2, z3), 0, false, 1, null), 0, 1, null);
|
||
|
}
|
||
|
|
||
|
private final Observable<Pair<Set<Long>, Set<Long>>> observeActiveJoinedThreadIdsWithPrevious() {
|
||
|
Observable<Pair<Set<Long>, Set<Long>>> Q = this.stream.getThreadsActiveJoined$app_productionBetaRelease().observeAllActiveJoinedThreadsById().G(StoreMessageAck$observeActiveJoinedThreadIdsWithPrevious$1.INSTANCE).s().Q(new Pair(n0.emptySet(), n0.emptySet()), StoreMessageAck$observeActiveJoinedThreadIdsWithPrevious$2.INSTANCE);
|
||
|
m.checkNotNullExpressionValue(Q, "stream\n .threadsA…oinedThreadIds)\n }");
|
||
|
return Q;
|
||
|
}
|
||
|
|
||
|
private final Observable<ThreadState> observeThreadState(long j) {
|
||
|
Observable<ThreadState> s2 = this.stream.getChannels$app_productionBetaRelease().observeChannel(j).Z(new StoreMessageAck$observeThreadState$1(this, j)).s();
|
||
|
m.checkNotNullExpressionValue(s2, "stream\n .channe… .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
private final void postPendingAck(Observable<PendingAck> observable, int i) {
|
||
|
StoreMessageAck$postPendingAck$1 storeMessageAck$postPendingAck$1 = new StoreMessageAck$postPendingAck$1(this, i);
|
||
|
Observable<PendingAck> y2 = observable.y(StoreMessageAck$postPendingAck$2.INSTANCE);
|
||
|
m.checkNotNullExpressionValue(y2, "filter { it != PendingAck.EMPTY }");
|
||
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.computationLatest(y2), observable.getClass(), (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreMessageAck$postPendingAck$3(storeMessageAck$postPendingAck$1), 62, (Object) null);
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ void postPendingAck$default(StoreMessageAck storeMessageAck, Observable observable, int i, int i2, Object obj) {
|
||
|
if ((i2 & 1) != 0) {
|
||
|
i = 0;
|
||
|
}
|
||
|
storeMessageAck.postPendingAck(observable, i);
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void pruneAcks() {
|
||
|
if (!(!this.stream.getGuilds$app_productionBetaRelease().getUnavailableGuildsInternal$app_productionBetaRelease().isEmpty())) {
|
||
|
Map<Long, Channel> channelsByIdInternal$app_productionBetaRelease = this.stream.getChannels$app_productionBetaRelease().getChannelsByIdInternal$app_productionBetaRelease();
|
||
|
Map<Long, StoreThreadsActiveJoined.ActiveJoinedThread> activeJoinedThreadsInternal$app_productionBetaRelease = this.stream.getThreadsActiveJoined$app_productionBetaRelease().getActiveJoinedThreadsInternal$app_productionBetaRelease();
|
||
|
Iterator<Long> it = this.acks.keySet().iterator();
|
||
|
while (it.hasNext()) {
|
||
|
long longValue = it.next().longValue();
|
||
|
if (!channelsByIdInternal$app_productionBetaRelease.containsKey(Long.valueOf(longValue)) && !activeJoinedThreadsInternal$app_productionBetaRelease.containsKey(Long.valueOf(longValue))) {
|
||
|
it.remove();
|
||
|
markChanged();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private final boolean shouldAck(ThreadState threadState) {
|
||
|
if (threadState instanceof ThreadState.NotThread) {
|
||
|
return true;
|
||
|
}
|
||
|
if (threadState instanceof ThreadState.Thread) {
|
||
|
return ((ThreadState.Thread) threadState).isActiveJoined();
|
||
|
}
|
||
|
throw new NoWhenBranchMatchedException();
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void updateAcks(long j, Ack ack) {
|
||
|
if (shouldAck(getThreadStateInternal(j))) {
|
||
|
Ack ack2 = this.acks.get(Long.valueOf(j));
|
||
|
if (ack2 == null || ModelMessage.compare(Long.valueOf(ack2.getMessageId()), Long.valueOf(ack.getMessageId())) != 0 || (ack.isLockedAck() && !ack2.isLockedAck())) {
|
||
|
this.acks.put(Long.valueOf(j), ack);
|
||
|
markChanged();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
private final void updateThreadAcks(Set<Long> set, Set<Long> set2) {
|
||
|
StoreThreadsActiveJoined.ActiveJoinedThread activeJoinedThread;
|
||
|
if (this.stream.getGuilds$app_productionBetaRelease().getUnavailableGuildsInternal$app_productionBetaRelease().isEmpty()) {
|
||
|
for (Number number : o0.minus((Set) set, (Iterable) set2)) {
|
||
|
long longValue = number.longValue();
|
||
|
if (this.acks.containsKey(Long.valueOf(longValue)) && this.acks.remove(Long.valueOf(longValue)) != null) {
|
||
|
markChanged();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
Map<Long, Long> guildsJoinedAtInternal$app_productionBetaRelease = this.stream.getGuilds$app_productionBetaRelease().getGuildsJoinedAtInternal$app_productionBetaRelease();
|
||
|
Map<Long, StoreThreadsActiveJoined.ActiveJoinedThread> activeJoinedThreadsInternal$app_productionBetaRelease = this.stream.getThreadsActiveJoined$app_productionBetaRelease().getActiveJoinedThreadsInternal$app_productionBetaRelease();
|
||
|
for (Number number2 : o0.minus((Set) set2, (Iterable) set)) {
|
||
|
long longValue2 = number2.longValue();
|
||
|
if (!this.acks.containsKey(Long.valueOf(longValue2)) && (activeJoinedThread = activeJoinedThreadsInternal$app_productionBetaRelease.get(Long.valueOf(longValue2))) != null) {
|
||
|
this.acks.put(Long.valueOf(longValue2), new Ack((ThreadUtils.getThreadAckMessageTimestamp$default(ThreadUtils.INSTANCE, activeJoinedThread.getChannel(), guildsJoinedAtInternal$app_productionBetaRelease.get(Long.valueOf(activeJoinedThread.getChannel().e())), Long.valueOf(activeJoinedThread.getJoinTimestamp().f()), null, 4, null) - 1420070400000L) << 22, false, false));
|
||
|
markChanged();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final void ack(long j, boolean z2, boolean z3) {
|
||
|
this.dispatcher.schedule(new StoreMessageAck$ack$1(this, j, z2, z3));
|
||
|
}
|
||
|
|
||
|
public final void ackGuild(Context context, long j, Function0<Unit> function0) {
|
||
|
m.checkNotNullParameter(function0, "onSuccess");
|
||
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.restSubscribeOn$default(this.restAPI.ackGuild(j), false, 1, null), context, "REST: ackGuild", (Function1) null, new StoreMessageAck$ackGuild$2(function0), (Function1) null, (Function0) null, (Function0) null, 116, (Object) null);
|
||
|
}
|
||
|
|
||
|
public final Map<Long, Ack> getAll() {
|
||
|
return this.acksSnapshot;
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final Map<Long, Ack> getAllInternal() {
|
||
|
return this.acks;
|
||
|
}
|
||
|
|
||
|
public final Ack getForChannel(long j) {
|
||
|
return getAll().get(Long.valueOf(j));
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleChannelSelected() {
|
||
|
for (Map.Entry<Long, Ack> entry : this.acks.entrySet()) {
|
||
|
this.acks.put(Long.valueOf(entry.getKey().longValue()), Ack.copy$default(entry.getValue(), 0, false, false, 3, null));
|
||
|
}
|
||
|
markChanged();
|
||
|
}
|
||
|
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:59:0x00cf A[SYNTHETIC] */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:62:0x007a A[SYNTHETIC] */
|
||
|
@StoreThread
|
||
|
public final void handleConnectionOpen(ModelPayload modelPayload) {
|
||
|
long j;
|
||
|
List<Channel> g;
|
||
|
Object obj;
|
||
|
UtcDateTime d;
|
||
|
boolean z2;
|
||
|
m.checkNotNullParameter(modelPayload, "payload");
|
||
|
ModelPayload.VersionedReadStates readState = modelPayload.getReadState();
|
||
|
m.checkNotNullExpressionValue(readState, "payload.readState");
|
||
|
if (!readState.isPartial()) {
|
||
|
this.acks.clear();
|
||
|
}
|
||
|
Map<Long, Ack> map = this.acks;
|
||
|
ModelPayload.VersionedReadStates readState2 = modelPayload.getReadState();
|
||
|
m.checkNotNullExpressionValue(readState2, "payload.readState");
|
||
|
List<ModelReadState> entries = readState2.getEntries();
|
||
|
m.checkNotNullExpressionValue(entries, "payload.readState.entries");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap(a.I(entries, 10, 16));
|
||
|
for (ModelReadState modelReadState : entries) {
|
||
|
Pair pair = o.to(Long.valueOf(modelReadState.getChannelId()), new Ack(modelReadState, false, false));
|
||
|
linkedHashMap.put(pair.getFirst(), pair.getSecond());
|
||
|
}
|
||
|
map.putAll(linkedHashMap);
|
||
|
List<Guild> guilds = modelPayload.getGuilds();
|
||
|
m.checkNotNullExpressionValue(guilds, "payload.guilds");
|
||
|
for (Guild guild : guilds) {
|
||
|
List<GuildMember> s2 = guild.s();
|
||
|
if (s2 != null) {
|
||
|
Iterator<T> it = s2.iterator();
|
||
|
while (true) {
|
||
|
if (!it.hasNext()) {
|
||
|
obj = null;
|
||
|
break;
|
||
|
}
|
||
|
obj = it.next();
|
||
|
if (((GuildMember) obj).j().i() == modelPayload.getMe().i()) {
|
||
|
z2 = true;
|
||
|
continue;
|
||
|
} else {
|
||
|
z2 = false;
|
||
|
continue;
|
||
|
}
|
||
|
if (z2) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
GuildMember guildMember = (GuildMember) obj;
|
||
|
if (!(guildMember == null || (d = guildMember.d()) == null)) {
|
||
|
j = d.f();
|
||
|
g = guild.g();
|
||
|
if (g == null) {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (Object obj2 : g) {
|
||
|
Channel channel = (Channel) obj2;
|
||
|
if (AnimatableValueParser.j1(channel) && !this.acks.containsKey(Long.valueOf(channel.g()))) {
|
||
|
arrayList.add(obj2);
|
||
|
}
|
||
|
}
|
||
|
ArrayList<Channel> arrayList2 = new ArrayList();
|
||
|
for (Object obj3 : arrayList) {
|
||
|
if ((((Channel) obj3).h() >>> 22) + 1420070400000L < j) {
|
||
|
arrayList2.add(obj3);
|
||
|
}
|
||
|
}
|
||
|
for (Channel channel2 : arrayList2) {
|
||
|
this.acks.put(Long.valueOf(channel2.g()), new Ack(channel2.h(), false, false));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
j = 0;
|
||
|
g = guild.g();
|
||
|
if (g == null) {
|
||
|
}
|
||
|
}
|
||
|
pruneAcks();
|
||
|
Subscription subscription = this.threadSyncSubscription;
|
||
|
if (subscription != null) {
|
||
|
subscription.unsubscribe();
|
||
|
}
|
||
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.computationLatest(observeActiveJoinedThreadIdsWithPrevious()), StoreMessageAck.class, (Context) null, new StoreMessageAck$handleConnectionOpen$3(this), (Function1) null, (Function0) null, (Function0) null, new StoreMessageAck$handleConnectionOpen$4(this), 58, (Object) null);
|
||
|
markChanged();
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleGuildCreate() {
|
||
|
pruneAcks();
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleMessageAck(ModelReadState modelReadState) {
|
||
|
m.checkNotNullParameter(modelReadState, "readState");
|
||
|
updateAcks(modelReadState.getChannelId(), new Ack(modelReadState, false, false));
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handleMessageCreate(ModelMessage modelMessage) {
|
||
|
m.checkNotNullParameter(modelMessage, "message");
|
||
|
if (modelMessage.getAuthor().i() == this.stream.getUsers$app_productionBetaRelease().getMeInternal$app_productionBetaRelease().getId()) {
|
||
|
updateAcks(modelMessage.getChannelId(), new Ack(modelMessage.getId(), false, false));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@StoreThread
|
||
|
public final void handlePreLogout() {
|
||
|
Subscription subscription = this.threadSyncSubscription;
|
||
|
if (subscription != null) {
|
||
|
subscription.unsubscribe();
|
||
|
}
|
||
|
this.threadSyncSubscription = null;
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.stores.Store
|
||
|
public void init(Context context) {
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
super.init(context);
|
||
|
Observable<R> Z = StoreStream.Companion.getChannelsSelected().observeId().s().Z(new StoreMessageAck$init$1(this));
|
||
|
m.checkNotNullExpressionValue(Z, "StoreStream\n .get… 0L\n }\n }");
|
||
|
Observable<Long> o = ObservableExtensionsKt.computationLatest(Z).o(500, TimeUnit.MILLISECONDS);
|
||
|
m.checkNotNullExpressionValue(o, "StoreStream\n .get…0, TimeUnit.MILLISECONDS)");
|
||
|
postPendingAck$default(this, getPendingAck(o, false, false), 0, 1, null);
|
||
|
}
|
||
|
|
||
|
public final void markUnread(long j, long j2) {
|
||
|
Observable j3 = Observable.j(this.stream.getMessages$app_productionBetaRelease().observeMessagesForChannel(j).y(StoreMessageAck$markUnread$1.INSTANCE), observeThreadState(j), StoreMessageAck$markUnread$2.INSTANCE);
|
||
|
m.checkNotNullExpressionValue(j3, "Observable\n .comb…lMessages, threadState) }");
|
||
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.takeSingleUntilTimeout(j3, 10, false), StoreMessageAck.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreMessageAck$markUnread$3(this, j2, j), 62, (Object) null);
|
||
|
}
|
||
|
|
||
|
public final Observable<Map<Long, Ack>> observeAll() {
|
||
|
Observable<Map<Long, Ack>> s2 = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreMessageAck$observeAll$1(this), 14, null).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observationDeck.connectR… .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
public final Observable<Ack> observeForChannel(long j) {
|
||
|
Observable<Ack> s2 = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreMessageAck$observeForChannel$1(this, j), 14, null).s();
|
||
|
m.checkNotNullExpressionValue(s2, "observationDeck.connectR… .distinctUntilChanged()");
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.stores.StoreV2
|
||
|
public void snapshotData() {
|
||
|
super.snapshotData();
|
||
|
HashMap hashMap = new HashMap(this.acks);
|
||
|
this.acksSnapshot = hashMap;
|
||
|
Persister.set$default(this.acksPersister, hashMap, false, 2, null);
|
||
|
}
|
||
|
}
|