discord-jadx/app/src/main/java/com/discord/stores/StoreMessageState.java

196 lines
7.5 KiB
Java

package com.discord.stores;
import c.d.b.a.a;
import com.discord.api.message.Message;
import com.discord.models.domain.ModelMessageDelete;
import d0.o;
import d0.t.h0;
import d0.t.n0;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
import rx.subjects.BehaviorSubject;
/* compiled from: StoreMessageState.kt */
public final class StoreMessageState {
private final Dispatcher dispatcher;
private final BehaviorSubject<Map<Long, State>> messageStateSubject;
/* compiled from: StoreMessageState.kt */
public static final class State {
private final Map<Integer, Set<String>> visibleSpoilerEmbedMap;
private final Set<Integer> visibleSpoilerNodeIndices;
public State() {
this(null, null, 3, null);
}
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: java.util.Map<java.lang.Integer, ? extends java.util.Set<java.lang.String>> */
/* JADX WARN: Multi-variable type inference failed */
public State(Set<Integer> set, Map<Integer, ? extends Set<String>> map) {
m.checkNotNullParameter(set, "visibleSpoilerNodeIndices");
m.checkNotNullParameter(map, "visibleSpoilerEmbedMap");
this.visibleSpoilerNodeIndices = set;
this.visibleSpoilerEmbedMap = map;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ State(Set set, Map map, int i, DefaultConstructorMarker defaultConstructorMarker) {
this((i & 1) != 0 ? n0.emptySet() : set, (i & 2) != 0 ? h0.emptyMap() : map);
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.stores.StoreMessageState$State */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ State copy$default(State state, Set set, Map map, int i, Object obj) {
if ((i & 1) != 0) {
set = state.visibleSpoilerNodeIndices;
}
if ((i & 2) != 0) {
map = state.visibleSpoilerEmbedMap;
}
return state.copy(set, map);
}
public final Set<Integer> component1() {
return this.visibleSpoilerNodeIndices;
}
public final Map<Integer, Set<String>> component2() {
return this.visibleSpoilerEmbedMap;
}
public final State copy(Set<Integer> set, Map<Integer, ? extends Set<String>> map) {
m.checkNotNullParameter(set, "visibleSpoilerNodeIndices");
m.checkNotNullParameter(map, "visibleSpoilerEmbedMap");
return new State(set, map);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof State)) {
return false;
}
State state = (State) obj;
return m.areEqual(this.visibleSpoilerNodeIndices, state.visibleSpoilerNodeIndices) && m.areEqual(this.visibleSpoilerEmbedMap, state.visibleSpoilerEmbedMap);
}
public final Map<Integer, Set<String>> getVisibleSpoilerEmbedMap() {
return this.visibleSpoilerEmbedMap;
}
public final Set<Integer> getVisibleSpoilerNodeIndices() {
return this.visibleSpoilerNodeIndices;
}
public int hashCode() {
Set<Integer> set = this.visibleSpoilerNodeIndices;
int i = 0;
int hashCode = (set != null ? set.hashCode() : 0) * 31;
Map<Integer, Set<String>> map = this.visibleSpoilerEmbedMap;
if (map != null) {
i = map.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder L = a.L("State(visibleSpoilerNodeIndices=");
L.append(this.visibleSpoilerNodeIndices);
L.append(", visibleSpoilerEmbedMap=");
return a.F(L, this.visibleSpoilerEmbedMap, ")");
}
}
public StoreMessageState(Dispatcher dispatcher) {
m.checkNotNullParameter(dispatcher, "dispatcher");
this.dispatcher = dispatcher;
BehaviorSubject<Map<Long, State>> l0 = BehaviorSubject.l0(h0.emptyMap());
m.checkNotNullExpressionValue(l0, "BehaviorSubject.create(emptyMap())");
this.messageStateSubject = l0;
}
public static final /* synthetic */ void access$updateState(StoreMessageState storeMessageState, long j, Function1 function1) {
storeMessageState.updateState(j, function1);
}
@StoreThread
private final void resetState(List<Long> list) {
Map<Long, State> n0 = this.messageStateSubject.n0();
ArrayList arrayList = new ArrayList();
for (Object obj : list) {
long longValue = ((Number) obj).longValue();
m.checkNotNullExpressionValue(n0, "messageStateMap");
if (n0.containsKey(Long.valueOf(longValue))) {
arrayList.add(obj);
}
}
if (!arrayList.isEmpty()) {
BehaviorSubject<Map<Long, State>> behaviorSubject = this.messageStateSubject;
m.checkNotNullExpressionValue(n0, "messageStateMap");
behaviorSubject.onNext(h0.minus((Map) n0, (Iterable) arrayList));
}
}
@StoreThread
private final void updateState(long j, Function1<? super State, State> function1) {
Map<Long, State> n0 = this.messageStateSubject.n0();
State state = n0.get(Long.valueOf(j));
if (state == null) {
state = new State(null, null, 3, null);
}
BehaviorSubject<Map<Long, State>> behaviorSubject = this.messageStateSubject;
m.checkNotNullExpressionValue(n0, "messageStateMap");
behaviorSubject.onNext(h0.plus(n0, o.to(Long.valueOf(j), function1.invoke(state))));
}
public final Observable<Map<Long, State>> getMessageState() {
Observable<Map<Long, State>> r = this.messageStateSubject.r();
m.checkNotNullExpressionValue(r, "messageStateSubject.distinctUntilChanged()");
return r;
}
@StoreThread
public final void handleChannelSelected() {
this.messageStateSubject.onNext(h0.emptyMap());
}
@StoreThread
public final void handleMessageDelete(ModelMessageDelete modelMessageDelete) {
m.checkNotNullParameter(modelMessageDelete, "messageDelete");
List<Long> messageIds = modelMessageDelete.getMessageIds();
m.checkNotNullExpressionValue(messageIds, "messageDelete.messageIds");
resetState(messageIds);
}
@StoreThread
public final void handleMessageUpdate(Message message) {
m.checkNotNullParameter(message, "message");
resetState(d0.t.m.listOf(Long.valueOf(message.o())));
}
public final void revealSpoiler(long j, int i) {
if (i >= 0) {
this.dispatcher.schedule(new StoreMessageState$revealSpoiler$1(this, j, i));
}
}
public final void revealSpoilerEmbed(long j, int i) {
if (i >= 0) {
this.dispatcher.schedule(new StoreMessageState$revealSpoilerEmbed$1(this, j, i));
}
}
public final void revealSpoilerEmbedData(long j, int i, String str) {
m.checkNotNullParameter(str, "key");
if (i >= 0) {
this.dispatcher.schedule(new StoreMessageState$revealSpoilerEmbedData$1(this, j, i, str));
}
}
}