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

497 lines
18 KiB
Java

package com.discord.stores;
import a0.a.a.b;
import androidx.recyclerview.widget.LinearLayoutManager;
import c.d.b.a.a;
import com.discord.models.message.Message;
import com.discord.models.user.User;
import com.discord.stores.updates.ObservationDeck;
import com.discord.stores.updates.ObservationDeckProvider;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2;
import com.discord.utilities.user.UserUtils;
import d0.t.n;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.List;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
import rx.subjects.PublishSubject;
/* compiled from: StoreChat.kt */
public final class StoreChat extends StoreV2 {
private final Dispatcher dispatcher;
private EditingMessage editingMessage;
private final PublishSubject<Event> eventSubject;
private final List<Long> expandedBlockedMessageGroups;
private List<Long> expandedBlockedMessageGroupsSnapshot;
private InteractionState interactionState;
private final ObservationDeck observationDeck;
/* compiled from: StoreChat.kt */
public static final class EditingMessage {
private final CharSequence content;
private final Message message;
public EditingMessage(Message message, CharSequence charSequence) {
m.checkNotNullParameter(message, "message");
m.checkNotNullParameter(charSequence, "content");
this.message = message;
this.content = charSequence;
}
public static /* synthetic */ EditingMessage copy$default(EditingMessage editingMessage, Message message, CharSequence charSequence, int i, Object obj) {
if ((i & 1) != 0) {
message = editingMessage.message;
}
if ((i & 2) != 0) {
charSequence = editingMessage.content;
}
return editingMessage.copy(message, charSequence);
}
public final Message component1() {
return this.message;
}
public final CharSequence component2() {
return this.content;
}
public final EditingMessage copy(Message message, CharSequence charSequence) {
m.checkNotNullParameter(message, "message");
m.checkNotNullParameter(charSequence, "content");
return new EditingMessage(message, charSequence);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof EditingMessage)) {
return false;
}
EditingMessage editingMessage = (EditingMessage) obj;
return m.areEqual(this.message, editingMessage.message) && m.areEqual(this.content, editingMessage.content);
}
public final CharSequence getContent() {
return this.content;
}
public final Message getMessage() {
return this.message;
}
public int hashCode() {
Message message = this.message;
int i = 0;
int hashCode = (message != null ? message.hashCode() : 0) * 31;
CharSequence charSequence = this.content;
if (charSequence != null) {
i = charSequence.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder L = a.L("EditingMessage(message=");
L.append(this.message);
L.append(", content=");
L.append(this.content);
L.append(")");
return L.toString();
}
}
/* compiled from: StoreChat.kt */
public static abstract class Event {
/* compiled from: StoreChat.kt */
public static final class AppendChatText extends Event {
private final String text;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AppendChatText(String str) {
super(null);
m.checkNotNullParameter(str, "text");
this.text = str;
}
public static /* synthetic */ AppendChatText copy$default(AppendChatText appendChatText, String str, int i, Object obj) {
if ((i & 1) != 0) {
str = appendChatText.text;
}
return appendChatText.copy(str);
}
public final String component1() {
return this.text;
}
public final AppendChatText copy(String str) {
m.checkNotNullParameter(str, "text");
return new AppendChatText(str);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof AppendChatText) && m.areEqual(this.text, ((AppendChatText) obj).text);
}
return true;
}
public final String getText() {
return this.text;
}
public int hashCode() {
String str = this.text;
if (str != null) {
return str.hashCode();
}
return 0;
}
public String toString() {
return a.D(a.L("AppendChatText(text="), this.text, ")");
}
}
/* compiled from: StoreChat.kt */
public static final class ReplaceChatText extends Event {
private final String text;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ReplaceChatText(String str) {
super(null);
m.checkNotNullParameter(str, "text");
this.text = str;
}
public static /* synthetic */ ReplaceChatText copy$default(ReplaceChatText replaceChatText, String str, int i, Object obj) {
if ((i & 1) != 0) {
str = replaceChatText.text;
}
return replaceChatText.copy(str);
}
public final String component1() {
return this.text;
}
public final ReplaceChatText copy(String str) {
m.checkNotNullParameter(str, "text");
return new ReplaceChatText(str);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof ReplaceChatText) && m.areEqual(this.text, ((ReplaceChatText) obj).text);
}
return true;
}
public final String getText() {
return this.text;
}
public int hashCode() {
String str = this.text;
if (str != null) {
return str.hashCode();
}
return 0;
}
public String toString() {
return a.D(a.L("ReplaceChatText(text="), this.text, ")");
}
}
private Event() {
}
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: StoreChat.kt */
public static final class InteractionState {
public static final Companion Companion = new Companion(null);
private static final int NEAR_EDGE_THRESHOLD = 15;
private static final int SCROLLED = 0;
private static final int SCROLLED_BOTTOM = 1;
private static final int SCROLLED_NEAR_BOTTOM = 4;
private static final int SCROLLED_TOP = 2;
private final long channelId;
private final boolean isAtBottom;
private final boolean isAtTop;
private final boolean isTouchedSinceLastJump;
private final long lastMessageId;
private final int scrollState$1;
/* compiled from: StoreChat.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ int access$getScrollState$p(Companion companion, LinearLayoutManager linearLayoutManager) {
return companion.getScrollState(linearLayoutManager);
}
private final int getScrollState(LinearLayoutManager linearLayoutManager) {
boolean z2 = false;
if (linearLayoutManager == null) {
return 0;
}
int itemCount = linearLayoutManager.getItemCount() - 1;
int findLastVisibleItemPosition = linearLayoutManager.findLastVisibleItemPosition();
int max = Math.max(0, itemCount - 15);
int findFirstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
boolean z3 = 1 <= findFirstVisibleItemPosition && 15 >= findFirstVisibleItemPosition;
int i = findFirstVisibleItemPosition <= 0 ? 1 : 0;
if (findLastVisibleItemPosition == itemCount || findLastVisibleItemPosition >= max) {
z2 = true;
}
if (z2) {
i |= 2;
}
return z3 ? i | 4 : i;
}
}
public InteractionState(long j, long j2, boolean z2, int i) {
this.channelId = j;
this.lastMessageId = j2;
this.isTouchedSinceLastJump = z2;
this.scrollState$1 = i;
boolean z3 = true;
this.isAtTop = z2 && isAtTopIgnoringTouch();
this.isAtBottom = (!z2 || !isAtBottomIgnoringTouch()) ? false : z3;
}
public InteractionState(long j, long j2, boolean z2, LinearLayoutManager linearLayoutManager) {
this(j, j2, z2, Companion.access$getScrollState$p(Companion, linearLayoutManager));
}
private final int component4() {
return this.scrollState$1;
}
public static /* synthetic */ InteractionState copy$default(InteractionState interactionState, long j, long j2, boolean z2, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
j = interactionState.channelId;
}
if ((i2 & 2) != 0) {
j2 = interactionState.lastMessageId;
}
if ((i2 & 4) != 0) {
z2 = interactionState.isTouchedSinceLastJump;
}
if ((i2 & 8) != 0) {
i = interactionState.scrollState$1;
}
return interactionState.copy(j, j2, z2, i);
}
public final long component1() {
return this.channelId;
}
public final long component2() {
return this.lastMessageId;
}
public final boolean component3() {
return this.isTouchedSinceLastJump;
}
public final InteractionState copy(long j, long j2, boolean z2, int i) {
return new InteractionState(j, j2, z2, i);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof InteractionState)) {
return false;
}
InteractionState interactionState = (InteractionState) obj;
return this.channelId == interactionState.channelId && this.lastMessageId == interactionState.lastMessageId && this.isTouchedSinceLastJump == interactionState.isTouchedSinceLastJump && this.scrollState$1 == interactionState.scrollState$1;
}
public final long getChannelId() {
return this.channelId;
}
public final long getLastMessageId() {
return this.lastMessageId;
}
public int hashCode() {
int a = (b.a(this.lastMessageId) + (b.a(this.channelId) * 31)) * 31;
boolean z2 = this.isTouchedSinceLastJump;
if (z2) {
z2 = true;
}
int i = z2 ? 1 : 0;
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
return ((a + i) * 31) + this.scrollState$1;
}
public final boolean isAtBottom() {
return this.isAtBottom;
}
public final boolean isAtBottomIgnoringTouch() {
return (this.scrollState$1 & 1) != 0;
}
public final boolean isAtTop() {
return this.isAtTop;
}
public final boolean isAtTopIgnoringTouch() {
return (this.scrollState$1 & 2) != 0;
}
public final boolean isNearBottomIgnoringTouch() {
return (this.scrollState$1 & 4) != 0;
}
public final boolean isTouchedSinceLastJump() {
return this.isTouchedSinceLastJump;
}
public String toString() {
StringBuilder L = a.L("InteractionState(channelId=");
L.append(this.channelId);
L.append(", lastMessageId=");
L.append(this.lastMessageId);
L.append(", isTouchedSinceLastJump=");
L.append(this.isTouchedSinceLastJump);
L.append(", scrollState=");
return a.z(L, this.scrollState$1, ")");
}
}
public StoreChat(Dispatcher dispatcher, ObservationDeck observationDeck) {
m.checkNotNullParameter(dispatcher, "dispatcher");
m.checkNotNullParameter(observationDeck, "observationDeck");
this.dispatcher = dispatcher;
this.observationDeck = observationDeck;
this.expandedBlockedMessageGroups = new ArrayList();
this.expandedBlockedMessageGroupsSnapshot = n.emptyList();
this.eventSubject = PublishSubject.k0();
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ StoreChat(Dispatcher dispatcher, ObservationDeck observationDeck, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(dispatcher, (i & 2) != 0 ? ObservationDeckProvider.get() : observationDeck);
}
public static final /* synthetic */ EditingMessage access$getEditingMessage$p(StoreChat storeChat) {
return storeChat.editingMessage;
}
public static final /* synthetic */ List access$getExpandedBlockedMessageGroups$p(StoreChat storeChat) {
return storeChat.expandedBlockedMessageGroups;
}
public static final /* synthetic */ InteractionState access$getInteractionState$p(StoreChat storeChat) {
return storeChat.interactionState;
}
public static final /* synthetic */ void access$setEditingMessage$p(StoreChat storeChat, EditingMessage editingMessage) {
storeChat.editingMessage = editingMessage;
}
public static final /* synthetic */ void access$setInteractionState$p(StoreChat storeChat, InteractionState interactionState) {
storeChat.interactionState = interactionState;
}
public final void appendMention(User user, long j) {
if (user != null) {
if (!(user.getUsername().length() == 0)) {
StoreGatewayConnection.requestGuildMembers$default(StoreStream.Companion.getGatewaySocket(), j, user.getUsername(), null, null, 12, null);
StringBuilder L = a.L("@");
L.append(user.getUsername());
L.append(UserUtils.INSTANCE.getDiscriminatorWithPadding(user));
String sb = L.toString();
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.j.onNext(new Event.AppendChatText(sb + ' '));
}
}
}
public final EditingMessage getEditingMessage() {
return this.editingMessage;
}
public final List<Long> getExpandedBlockedMessageGroups() {
return this.expandedBlockedMessageGroupsSnapshot;
}
public final InteractionState getInteractionState() {
return this.interactionState;
}
public final Observable<EditingMessage> observeEditingMessage() {
Observable<EditingMessage> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChat$observeEditingMessage$1(this), 14, null).r();
m.checkNotNullExpressionValue(r, "observationDeck.connectR… }.distinctUntilChanged()");
return r;
}
public final Observable<Event> observeEvents() {
PublishSubject<Event> publishSubject = this.eventSubject;
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
return publishSubject;
}
public final Observable<List<Long>> observeExpandedBlockedMessageIds() {
Observable<List<Long>> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChat$observeExpandedBlockedMessageIds$1(this), 14, null).r();
m.checkNotNullExpressionValue(r, "observationDeck.connectR… }.distinctUntilChanged()");
return r;
}
public final Observable<InteractionState> observeInteractionState() {
Observable F = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreChat$observeInteractionState$1(this), 14, null).x(ObservableExtensionsKt$filterNull$1.INSTANCE).F(ObservableExtensionsKt$filterNull$2.INSTANCE);
m.checkNotNullExpressionValue(F, "filter { it != null }.map { it!! }");
Observable<InteractionState> r = F.r();
m.checkNotNullExpressionValue(r, "observationDeck.connectR… .distinctUntilChanged()");
return r;
}
public final void replaceChatText(String str) {
m.checkNotNullParameter(str, "text");
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.j.onNext(new Event.ReplaceChatText(str + ' '));
}
public final void setEditingMessage(EditingMessage editingMessage) {
this.dispatcher.schedule(new StoreChat$setEditingMessage$1(this, editingMessage));
}
public final void setInteractionState(InteractionState interactionState) {
m.checkNotNullParameter(interactionState, "interactionState");
this.dispatcher.schedule(new StoreChat$setInteractionState$1(this, interactionState));
}
@Override // com.discord.stores.StoreV2
public void snapshotData() {
super.snapshotData();
this.expandedBlockedMessageGroupsSnapshot = new ArrayList(this.expandedBlockedMessageGroups);
}
public final void toggleBlockedMessageGroup(long j) {
this.dispatcher.schedule(new StoreChat$toggleBlockedMessageGroup$1(this, j));
}
}