discord-jadx/app/src/main/java/com/discord/widgets/friends/FriendsListViewModel.java

1777 lines
76 KiB
Java

package com.discord.widgets.friends;
import a0.a.a.b;
import android.content.Context;
import androidx.annotation.MainThread;
import androidx.annotation.StringRes;
import b.d.b.a.a;
import com.discord.R;
import com.discord.api.presence.ClientStatus;
import com.discord.app.AppViewModel;
import com.discord.models.domain.ModelApplicationStream;
import com.discord.models.domain.ModelUserRelationship;
import com.discord.models.friendsuggestions.FriendSuggestion;
import com.discord.models.presence.Presence;
import com.discord.models.user.User;
import com.discord.stores.StoreChannels;
import com.discord.stores.StoreChannelsSelected;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreUser;
import com.discord.stores.StoreUserConnections;
import com.discord.stores.StoreUserPresence;
import com.discord.stores.StoreUserRelationships;
import com.discord.stores.updates.ObservationDeck;
import com.discord.stores.updates.ObservationDeckProvider;
import com.discord.utilities.captcha.CaptchaHelper;
import com.discord.utilities.error.Error;
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
import com.discord.utilities.rest.RestAPI;
import com.discord.utilities.rx.ObservableExtensionsKt;
import d0.t.i0;
import d0.t.n;
import d0.t.n0;
import d0.t.q;
import d0.t.u;
import d0.z.d.m;
import d0.z.d.o;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Ref$ObjectRef;
import rx.Emitter;
import rx.Observable;
import rx.functions.Cancellable;
import rx.subjects.PublishSubject;
/* compiled from: FriendsListViewModel.kt */
public final class FriendsListViewModel extends AppViewModel<ViewState> {
private static final int COLLAPSED_ITEM_COUNT = 2;
public static final Companion Companion = new Companion(null);
private static final String LOCATION = "Friends List";
private Cancellable computeItemJob;
private final PublishSubject<Event> eventSubject;
private boolean isPendingSectionExpanded;
private boolean isSuggestedSectionExpanded;
private ListSections listSections;
private final RestAPI restAPI;
private final StoreChannels storeChannels;
private final Observable<StoreState> storeObservable;
/* compiled from: FriendsListViewModel.kt */
/* renamed from: com.discord.widgets.friends.FriendsListViewModel$1 reason: invalid class name */
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
public final /* synthetic */ FriendsListViewModel this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1(FriendsListViewModel friendsListViewModel) {
super(1);
this.this$0 = friendsListViewModel;
}
/* 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(StoreState storeState) {
invoke(storeState);
return Unit.a;
}
public final void invoke(StoreState storeState) {
m.checkNotNullParameter(storeState, "storeState");
FriendsListViewModel.access$handleStoreState(this.this$0, storeState);
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final Observable<StoreState> observeStores() {
StoreStream.Companion companion = StoreStream.Companion;
StoreChannelsSelected channelsSelected = companion.getChannelsSelected();
StoreUserPresence presences = companion.getPresences();
StoreUser users = companion.getUsers();
StoreUserRelationships userRelationships = companion.getUserRelationships();
StoreUserConnections userConnections = companion.getUserConnections();
Observable<StoreState> F = ObservableExtensionsKt.leadingEdgeThrottle(ObservationDeck.connectRx$default(ObservationDeckProvider.get(), new ObservationDeck.UpdateSource[]{companion.getChannelsSelected(), companion.getPresences(), companion.getUsers(), companion.getUserRelationships(), companion.getApplicationStreaming(), companion.getUserConnections(), companion.getExperiments(), companion.getContactSync()}, false, null, null, 14, null), 1, TimeUnit.SECONDS).F(new FriendsListViewModel$Companion$observeStores$1(channelsSelected, presences, users, userRelationships, companion.getApplicationStreaming(), userConnections, companion.getExperiments(), companion.getContactSync(), companion.getFriendSuggestions()));
m.checkNotNullExpressionValue(F, "ObservationDeckProvider\n… )\n }");
return F;
}
}
/* compiled from: FriendsListViewModel.kt */
public static abstract class Event {
/* compiled from: FriendsListViewModel.kt */
public static final class CaptchaError extends Event {
private final int discriminator;
private final Error error;
private final String username;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public CaptchaError(Error error, String str, int i) {
super(null);
m.checkNotNullParameter(error, "error");
m.checkNotNullParameter(str, "username");
this.error = error;
this.username = str;
this.discriminator = i;
}
public static /* synthetic */ CaptchaError copy$default(CaptchaError captchaError, Error error, String str, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
error = captchaError.error;
}
if ((i2 & 2) != 0) {
str = captchaError.username;
}
if ((i2 & 4) != 0) {
i = captchaError.discriminator;
}
return captchaError.copy(error, str, i);
}
public final Error component1() {
return this.error;
}
public final String component2() {
return this.username;
}
public final int component3() {
return this.discriminator;
}
public final CaptchaError copy(Error error, String str, int i) {
m.checkNotNullParameter(error, "error");
m.checkNotNullParameter(str, "username");
return new CaptchaError(error, str, i);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CaptchaError)) {
return false;
}
CaptchaError captchaError = (CaptchaError) obj;
return m.areEqual(this.error, captchaError.error) && m.areEqual(this.username, captchaError.username) && this.discriminator == captchaError.discriminator;
}
public final int getDiscriminator() {
return this.discriminator;
}
public final Error getError() {
return this.error;
}
public final String getUsername() {
return this.username;
}
public int hashCode() {
Error error = this.error;
int i = 0;
int hashCode = (error != null ? error.hashCode() : 0) * 31;
String str = this.username;
if (str != null) {
i = str.hashCode();
}
return ((hashCode + i) * 31) + this.discriminator;
}
public String toString() {
StringBuilder R = a.R("CaptchaError(error=");
R.append(this.error);
R.append(", username=");
R.append(this.username);
R.append(", discriminator=");
return a.A(R, this.discriminator, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class LaunchVoiceCall extends Event {
private final long channelId;
public LaunchVoiceCall(long j) {
super(null);
this.channelId = j;
}
public static /* synthetic */ LaunchVoiceCall copy$default(LaunchVoiceCall launchVoiceCall, long j, int i, Object obj) {
if ((i & 1) != 0) {
j = launchVoiceCall.channelId;
}
return launchVoiceCall.copy(j);
}
public final long component1() {
return this.channelId;
}
public final LaunchVoiceCall copy(long j) {
return new LaunchVoiceCall(j);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof LaunchVoiceCall) && this.channelId == ((LaunchVoiceCall) obj).channelId;
}
return true;
}
public final long getChannelId() {
return this.channelId;
}
public int hashCode() {
return b.a(this.channelId);
}
public String toString() {
return a.B(a.R("LaunchVoiceCall(channelId="), this.channelId, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class ShowFriendRequestErrorToast extends Event {
private final int abortCode;
private final String username;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ShowFriendRequestErrorToast(int i, String str) {
super(null);
m.checkNotNullParameter(str, "username");
this.abortCode = i;
this.username = str;
}
public static /* synthetic */ ShowFriendRequestErrorToast copy$default(ShowFriendRequestErrorToast showFriendRequestErrorToast, int i, String str, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = showFriendRequestErrorToast.abortCode;
}
if ((i2 & 2) != 0) {
str = showFriendRequestErrorToast.username;
}
return showFriendRequestErrorToast.copy(i, str);
}
public final int component1() {
return this.abortCode;
}
public final String component2() {
return this.username;
}
public final ShowFriendRequestErrorToast copy(int i, String str) {
m.checkNotNullParameter(str, "username");
return new ShowFriendRequestErrorToast(i, str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ShowFriendRequestErrorToast)) {
return false;
}
ShowFriendRequestErrorToast showFriendRequestErrorToast = (ShowFriendRequestErrorToast) obj;
return this.abortCode == showFriendRequestErrorToast.abortCode && m.areEqual(this.username, showFriendRequestErrorToast.username);
}
public final int getAbortCode() {
return this.abortCode;
}
public final String getUsername() {
return this.username;
}
public int hashCode() {
int i = this.abortCode * 31;
String str = this.username;
return i + (str != null ? str.hashCode() : 0);
}
public String toString() {
StringBuilder R = a.R("ShowFriendRequestErrorToast(abortCode=");
R.append(this.abortCode);
R.append(", username=");
return a.H(R, this.username, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class ShowToast extends Event {
private final int stringRes;
public ShowToast(int i) {
super(null);
this.stringRes = i;
}
public static /* synthetic */ ShowToast copy$default(ShowToast showToast, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = showToast.stringRes;
}
return showToast.copy(i);
}
public final int component1() {
return this.stringRes;
}
public final ShowToast copy(int i) {
return new ShowToast(i);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof ShowToast) && this.stringRes == ((ShowToast) obj).stringRes;
}
return true;
}
public final int getStringRes() {
return this.stringRes;
}
public int hashCode() {
return this.stringRes;
}
public String toString() {
return a.A(a.R("ShowToast(stringRes="), this.stringRes, ")");
}
}
private Event() {
}
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: FriendsListViewModel.kt */
public static abstract class Item implements MGRecyclerDataPayload {
public static final Companion Companion = new Companion(null);
public static final int TYPE_CONTACT_SYNC_UPSELL = 6;
public static final int TYPE_FRIEND = 0;
public static final int TYPE_HEADER = 3;
public static final int TYPE_PENDING_FRIEND = 1;
public static final int TYPE_PENDING_HEADER = 2;
public static final int TYPE_SUGGESTED_FRIEND = 5;
public static final int TYPE_SUGGESTED_FRIEND_HEADER = 4;
private final int type;
/* compiled from: FriendsListViewModel.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class ContactSyncUpsell extends Item {
private final boolean dismissed;
private final String key = String.valueOf(getType());
public ContactSyncUpsell(boolean z2) {
super(6, null);
this.dismissed = z2;
}
public static /* synthetic */ ContactSyncUpsell copy$default(ContactSyncUpsell contactSyncUpsell, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
z2 = contactSyncUpsell.dismissed;
}
return contactSyncUpsell.copy(z2);
}
public final boolean component1() {
return this.dismissed;
}
public final ContactSyncUpsell copy(boolean z2) {
return new ContactSyncUpsell(z2);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof ContactSyncUpsell) && this.dismissed == ((ContactSyncUpsell) obj).dismissed;
}
return true;
}
public final boolean getDismissed() {
return this.dismissed;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public int hashCode() {
boolean z2 = this.dismissed;
if (z2) {
return 1;
}
return z2 ? 1 : 0;
}
public String toString() {
return a.M(a.R("ContactSyncUpsell(dismissed="), this.dismissed, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class Friend extends Item {
private final boolean isApplicationStreaming;
private final String key;
private final Presence presence;
private final User user;
/* JADX DEBUG: TODO: convert one arg to string using `String.valueOf()`, args: [(wrap: int : 0x0015: INVOKE (r5v1 int) = (r2v0 'this' com.discord.widgets.friends.FriendsListViewModel$Item$Friend A[IMMUTABLE_TYPE, THIS]) type: VIRTUAL call: com.discord.widgets.friends.FriendsListViewModel.Item.getType():int), (wrap: long : 0x001c: INVOKE (r0v2 long) = (r3v0 com.discord.models.user.User) type: INTERFACE call: com.discord.models.user.User.getId():long)] */
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Friend(User user, Presence presence, boolean z2) {
super(0, null);
m.checkNotNullParameter(user, "user");
this.user = user;
this.presence = presence;
this.isApplicationStreaming = z2;
StringBuilder sb = new StringBuilder();
sb.append(getType());
sb.append(user.getId());
this.key = sb.toString();
}
public static /* synthetic */ Friend copy$default(Friend friend, User user, Presence presence, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
user = friend.user;
}
if ((i & 2) != 0) {
presence = friend.presence;
}
if ((i & 4) != 0) {
z2 = friend.isApplicationStreaming;
}
return friend.copy(user, presence, z2);
}
public final User component1() {
return this.user;
}
public final Presence component2() {
return this.presence;
}
public final boolean component3() {
return this.isApplicationStreaming;
}
public final Friend copy(User user, Presence presence, boolean z2) {
m.checkNotNullParameter(user, "user");
return new Friend(user, presence, z2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Friend)) {
return false;
}
Friend friend = (Friend) obj;
return m.areEqual(this.user, friend.user) && m.areEqual(this.presence, friend.presence) && this.isApplicationStreaming == friend.isApplicationStreaming;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public final Presence getPresence() {
return this.presence;
}
public final User getUser() {
return this.user;
}
public int hashCode() {
User user = this.user;
int i = 0;
int hashCode = (user != null ? user.hashCode() : 0) * 31;
Presence presence = this.presence;
if (presence != null) {
i = presence.hashCode();
}
int i2 = (hashCode + i) * 31;
boolean z2 = this.isApplicationStreaming;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
return i2 + i3;
}
public final boolean isApplicationStreaming() {
return this.isApplicationStreaming;
}
public final boolean isOnline() {
return this.presence != null && n0.setOf(new ClientStatus[]{ClientStatus.ONLINE, ClientStatus.IDLE, ClientStatus.DND}).contains(this.presence.getStatus());
}
public String toString() {
StringBuilder R = a.R("Friend(user=");
R.append(this.user);
R.append(", presence=");
R.append(this.presence);
R.append(", isApplicationStreaming=");
return a.M(R, this.isApplicationStreaming, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class Header extends Item {
private final int count;
private final String key;
private final int titleStringResId;
/* JADX DEBUG: TODO: convert one arg to string using `String.valueOf()`, args: [(wrap: int : 0x000e: INVOKE (r0v1 int) = (r2v0 'this' com.discord.widgets.friends.FriendsListViewModel$Item$Header A[IMMUTABLE_TYPE, THIS]) type: VIRTUAL call: com.discord.widgets.friends.FriendsListViewModel.Item.getType():int), (r3v0 int)] */
public Header(@StringRes int i, int i2) {
super(3, null);
this.titleStringResId = i;
this.count = i2;
StringBuilder sb = new StringBuilder();
sb.append(getType());
sb.append(i);
this.key = sb.toString();
}
public static /* synthetic */ Header copy$default(Header header, int i, int i2, int i3, Object obj) {
if ((i3 & 1) != 0) {
i = header.titleStringResId;
}
if ((i3 & 2) != 0) {
i2 = header.count;
}
return header.copy(i, i2);
}
public final int component1() {
return this.titleStringResId;
}
public final int component2() {
return this.count;
}
public final Header copy(@StringRes int i, int i2) {
return new Header(i, i2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Header)) {
return false;
}
Header header = (Header) obj;
return this.titleStringResId == header.titleStringResId && this.count == header.count;
}
public final int getCount() {
return this.count;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public final int getTitleStringResId() {
return this.titleStringResId;
}
public int hashCode() {
return (this.titleStringResId * 31) + this.count;
}
public String toString() {
StringBuilder R = a.R("Header(titleStringResId=");
R.append(this.titleStringResId);
R.append(", count=");
return a.A(R, this.count, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class PendingFriendRequest extends Item {
private final String key;
private final Presence presence;
private final int relationshipType;
private final User user;
/* JADX DEBUG: TODO: convert one arg to string using `String.valueOf()`, args: [(wrap: int : 0x0015: INVOKE (r5v1 int) = (r2v0 'this' com.discord.widgets.friends.FriendsListViewModel$Item$PendingFriendRequest A[IMMUTABLE_TYPE, THIS]) type: VIRTUAL call: com.discord.widgets.friends.FriendsListViewModel.Item.getType():int), (wrap: long : 0x001c: INVOKE (r0v2 long) = (r3v0 com.discord.models.user.User) type: INTERFACE call: com.discord.models.user.User.getId():long)] */
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public PendingFriendRequest(User user, Presence presence, int i) {
super(1, null);
m.checkNotNullParameter(user, "user");
this.user = user;
this.presence = presence;
this.relationshipType = i;
StringBuilder sb = new StringBuilder();
sb.append(getType());
sb.append(user.getId());
this.key = sb.toString();
}
public static /* synthetic */ PendingFriendRequest copy$default(PendingFriendRequest pendingFriendRequest, User user, Presence presence, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
user = pendingFriendRequest.user;
}
if ((i2 & 2) != 0) {
presence = pendingFriendRequest.presence;
}
if ((i2 & 4) != 0) {
i = pendingFriendRequest.relationshipType;
}
return pendingFriendRequest.copy(user, presence, i);
}
public final User component1() {
return this.user;
}
public final Presence component2() {
return this.presence;
}
public final int component3() {
return this.relationshipType;
}
public final PendingFriendRequest copy(User user, Presence presence, int i) {
m.checkNotNullParameter(user, "user");
return new PendingFriendRequest(user, presence, i);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PendingFriendRequest)) {
return false;
}
PendingFriendRequest pendingFriendRequest = (PendingFriendRequest) obj;
return m.areEqual(this.user, pendingFriendRequest.user) && m.areEqual(this.presence, pendingFriendRequest.presence) && this.relationshipType == pendingFriendRequest.relationshipType;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public final Presence getPresence() {
return this.presence;
}
public final int getRelationshipType() {
return this.relationshipType;
}
public final User getUser() {
return this.user;
}
public int hashCode() {
User user = this.user;
int i = 0;
int hashCode = (user != null ? user.hashCode() : 0) * 31;
Presence presence = this.presence;
if (presence != null) {
i = presence.hashCode();
}
return ((hashCode + i) * 31) + this.relationshipType;
}
public String toString() {
StringBuilder R = a.R("PendingFriendRequest(user=");
R.append(this.user);
R.append(", presence=");
R.append(this.presence);
R.append(", relationshipType=");
return a.A(R, this.relationshipType, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class PendingHeader extends Item {
private final int count;
private final boolean isPendingSectionExpanded;
private final String key = String.valueOf(getType());
private final boolean showExpandButton;
private final int titleStringResId;
public PendingHeader(@StringRes int i, int i2, boolean z2, boolean z3) {
super(2, null);
this.titleStringResId = i;
this.count = i2;
this.isPendingSectionExpanded = z2;
this.showExpandButton = z3;
}
public static /* synthetic */ PendingHeader copy$default(PendingHeader pendingHeader, int i, int i2, boolean z2, boolean z3, int i3, Object obj) {
if ((i3 & 1) != 0) {
i = pendingHeader.titleStringResId;
}
if ((i3 & 2) != 0) {
i2 = pendingHeader.count;
}
if ((i3 & 4) != 0) {
z2 = pendingHeader.isPendingSectionExpanded;
}
if ((i3 & 8) != 0) {
z3 = pendingHeader.showExpandButton;
}
return pendingHeader.copy(i, i2, z2, z3);
}
public final int component1() {
return this.titleStringResId;
}
public final int component2() {
return this.count;
}
public final boolean component3() {
return this.isPendingSectionExpanded;
}
public final boolean component4() {
return this.showExpandButton;
}
public final PendingHeader copy(@StringRes int i, int i2, boolean z2, boolean z3) {
return new PendingHeader(i, i2, z2, z3);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PendingHeader)) {
return false;
}
PendingHeader pendingHeader = (PendingHeader) obj;
return this.titleStringResId == pendingHeader.titleStringResId && this.count == pendingHeader.count && this.isPendingSectionExpanded == pendingHeader.isPendingSectionExpanded && this.showExpandButton == pendingHeader.showExpandButton;
}
public final int getCount() {
return this.count;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public final boolean getShowExpandButton() {
return this.showExpandButton;
}
public final int getTitleStringResId() {
return this.titleStringResId;
}
public int hashCode() {
int i = ((this.titleStringResId * 31) + this.count) * 31;
boolean z2 = this.isPendingSectionExpanded;
int i2 = 1;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
int i6 = (i + i3) * 31;
boolean z3 = this.showExpandButton;
if (!z3) {
i2 = z3 ? 1 : 0;
}
return i6 + i2;
}
public final boolean isPendingSectionExpanded() {
return this.isPendingSectionExpanded;
}
public String toString() {
StringBuilder R = a.R("PendingHeader(titleStringResId=");
R.append(this.titleStringResId);
R.append(", count=");
R.append(this.count);
R.append(", isPendingSectionExpanded=");
R.append(this.isPendingSectionExpanded);
R.append(", showExpandButton=");
return a.M(R, this.showExpandButton, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class SuggestedFriend extends Item {
private final String key;
private final FriendSuggestion suggestion;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public SuggestedFriend(FriendSuggestion friendSuggestion) {
super(5, null);
m.checkNotNullParameter(friendSuggestion, "suggestion");
this.suggestion = friendSuggestion;
this.key = getType() + " -- " + friendSuggestion.getUser().getId();
}
public static /* synthetic */ SuggestedFriend copy$default(SuggestedFriend suggestedFriend, FriendSuggestion friendSuggestion, int i, Object obj) {
if ((i & 1) != 0) {
friendSuggestion = suggestedFriend.suggestion;
}
return suggestedFriend.copy(friendSuggestion);
}
public final FriendSuggestion component1() {
return this.suggestion;
}
public final SuggestedFriend copy(FriendSuggestion friendSuggestion) {
m.checkNotNullParameter(friendSuggestion, "suggestion");
return new SuggestedFriend(friendSuggestion);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof SuggestedFriend) && m.areEqual(this.suggestion, ((SuggestedFriend) obj).suggestion);
}
return true;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public final FriendSuggestion getSuggestion() {
return this.suggestion;
}
public int hashCode() {
FriendSuggestion friendSuggestion = this.suggestion;
if (friendSuggestion != null) {
return friendSuggestion.hashCode();
}
return 0;
}
public String toString() {
StringBuilder R = a.R("SuggestedFriend(suggestion=");
R.append(this.suggestion);
R.append(")");
return R.toString();
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class SuggestedFriendsHeader extends Item {
private final int count;
private final boolean isExpanded;
private final String key = String.valueOf(getType());
private final boolean showExpandButton;
public SuggestedFriendsHeader(int i, boolean z2, boolean z3) {
super(4, null);
this.count = i;
this.isExpanded = z2;
this.showExpandButton = z3;
}
public static /* synthetic */ SuggestedFriendsHeader copy$default(SuggestedFriendsHeader suggestedFriendsHeader, int i, boolean z2, boolean z3, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = suggestedFriendsHeader.count;
}
if ((i2 & 2) != 0) {
z2 = suggestedFriendsHeader.isExpanded;
}
if ((i2 & 4) != 0) {
z3 = suggestedFriendsHeader.showExpandButton;
}
return suggestedFriendsHeader.copy(i, z2, z3);
}
public final int component1() {
return this.count;
}
public final boolean component2() {
return this.isExpanded;
}
public final boolean component3() {
return this.showExpandButton;
}
public final SuggestedFriendsHeader copy(int i, boolean z2, boolean z3) {
return new SuggestedFriendsHeader(i, z2, z3);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof SuggestedFriendsHeader)) {
return false;
}
SuggestedFriendsHeader suggestedFriendsHeader = (SuggestedFriendsHeader) obj;
return this.count == suggestedFriendsHeader.count && this.isExpanded == suggestedFriendsHeader.isExpanded && this.showExpandButton == suggestedFriendsHeader.showExpandButton;
}
public final int getCount() {
return this.count;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public final boolean getShowExpandButton() {
return this.showExpandButton;
}
public int hashCode() {
int i = this.count * 31;
boolean z2 = this.isExpanded;
int i2 = 1;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
int i6 = (i + i3) * 31;
boolean z3 = this.showExpandButton;
if (!z3) {
i2 = z3 ? 1 : 0;
}
return i6 + i2;
}
public final boolean isExpanded() {
return this.isExpanded;
}
public String toString() {
StringBuilder R = a.R("SuggestedFriendsHeader(count=");
R.append(this.count);
R.append(", isExpanded=");
R.append(this.isExpanded);
R.append(", showExpandButton=");
return a.M(R, this.showExpandButton, ")");
}
}
private Item(int i) {
this.type = i;
}
public /* synthetic */ Item(int i, DefaultConstructorMarker defaultConstructorMarker) {
this(i);
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
public int getType() {
return this.type;
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class ListSections {
private final Item.ContactSyncUpsell contactSyncUpsell;
private final List<Item> friendsItemsWithHeaders;
private final Item.PendingHeader pendingHeaderItem;
private final List<Item> pendingItems;
private final List<Item.SuggestedFriend> suggestedFriendItems;
private final Item.SuggestedFriendsHeader suggestionsHeaderItem;
/* JADX DEBUG: Multi-variable search result rejected for r5v0, resolved type: java.util.List<? extends com.discord.widgets.friends.FriendsListViewModel$Item> */
/* JADX DEBUG: Multi-variable search result rejected for r6v0, resolved type: java.util.List<? extends com.discord.widgets.friends.FriendsListViewModel$Item> */
/* JADX WARN: Multi-variable type inference failed */
public ListSections(Item.SuggestedFriendsHeader suggestedFriendsHeader, List<Item.SuggestedFriend> list, Item.PendingHeader pendingHeader, List<? extends Item> list2, List<? extends Item> list3, Item.ContactSyncUpsell contactSyncUpsell) {
m.checkNotNullParameter(list, "suggestedFriendItems");
m.checkNotNullParameter(list2, "pendingItems");
m.checkNotNullParameter(list3, "friendsItemsWithHeaders");
this.suggestionsHeaderItem = suggestedFriendsHeader;
this.suggestedFriendItems = list;
this.pendingHeaderItem = pendingHeader;
this.pendingItems = list2;
this.friendsItemsWithHeaders = list3;
this.contactSyncUpsell = contactSyncUpsell;
}
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: com.discord.widgets.friends.FriendsListViewModel$ListSections */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ ListSections copy$default(ListSections listSections, Item.SuggestedFriendsHeader suggestedFriendsHeader, List list, Item.PendingHeader pendingHeader, List list2, List list3, Item.ContactSyncUpsell contactSyncUpsell, int i, Object obj) {
if ((i & 1) != 0) {
suggestedFriendsHeader = listSections.suggestionsHeaderItem;
}
if ((i & 2) != 0) {
list = listSections.suggestedFriendItems;
}
if ((i & 4) != 0) {
pendingHeader = listSections.pendingHeaderItem;
}
if ((i & 8) != 0) {
list2 = listSections.pendingItems;
}
if ((i & 16) != 0) {
list3 = listSections.friendsItemsWithHeaders;
}
if ((i & 32) != 0) {
contactSyncUpsell = listSections.contactSyncUpsell;
}
return listSections.copy(suggestedFriendsHeader, list, pendingHeader, list2, list3, contactSyncUpsell);
}
public final Item.SuggestedFriendsHeader component1() {
return this.suggestionsHeaderItem;
}
public final List<Item.SuggestedFriend> component2() {
return this.suggestedFriendItems;
}
public final Item.PendingHeader component3() {
return this.pendingHeaderItem;
}
public final List<Item> component4() {
return this.pendingItems;
}
public final List<Item> component5() {
return this.friendsItemsWithHeaders;
}
public final Item.ContactSyncUpsell component6() {
return this.contactSyncUpsell;
}
public final ListSections copy(Item.SuggestedFriendsHeader suggestedFriendsHeader, List<Item.SuggestedFriend> list, Item.PendingHeader pendingHeader, List<? extends Item> list2, List<? extends Item> list3, Item.ContactSyncUpsell contactSyncUpsell) {
m.checkNotNullParameter(list, "suggestedFriendItems");
m.checkNotNullParameter(list2, "pendingItems");
m.checkNotNullParameter(list3, "friendsItemsWithHeaders");
return new ListSections(suggestedFriendsHeader, list, pendingHeader, list2, list3, contactSyncUpsell);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ListSections)) {
return false;
}
ListSections listSections = (ListSections) obj;
return m.areEqual(this.suggestionsHeaderItem, listSections.suggestionsHeaderItem) && m.areEqual(this.suggestedFriendItems, listSections.suggestedFriendItems) && m.areEqual(this.pendingHeaderItem, listSections.pendingHeaderItem) && m.areEqual(this.pendingItems, listSections.pendingItems) && m.areEqual(this.friendsItemsWithHeaders, listSections.friendsItemsWithHeaders) && m.areEqual(this.contactSyncUpsell, listSections.contactSyncUpsell);
}
public final Item.ContactSyncUpsell getContactSyncUpsell() {
return this.contactSyncUpsell;
}
public final List<Item> getFriendsItemsWithHeaders() {
return this.friendsItemsWithHeaders;
}
public final Item.PendingHeader getPendingHeaderItem() {
return this.pendingHeaderItem;
}
public final List<Item> getPendingItems() {
return this.pendingItems;
}
public final List<Item.SuggestedFriend> getSuggestedFriendItems() {
return this.suggestedFriendItems;
}
public final Item.SuggestedFriendsHeader getSuggestionsHeaderItem() {
return this.suggestionsHeaderItem;
}
public int hashCode() {
Item.SuggestedFriendsHeader suggestedFriendsHeader = this.suggestionsHeaderItem;
int i = 0;
int hashCode = (suggestedFriendsHeader != null ? suggestedFriendsHeader.hashCode() : 0) * 31;
List<Item.SuggestedFriend> list = this.suggestedFriendItems;
int hashCode2 = (hashCode + (list != null ? list.hashCode() : 0)) * 31;
Item.PendingHeader pendingHeader = this.pendingHeaderItem;
int hashCode3 = (hashCode2 + (pendingHeader != null ? pendingHeader.hashCode() : 0)) * 31;
List<Item> list2 = this.pendingItems;
int hashCode4 = (hashCode3 + (list2 != null ? list2.hashCode() : 0)) * 31;
List<Item> list3 = this.friendsItemsWithHeaders;
int hashCode5 = (hashCode4 + (list3 != null ? list3.hashCode() : 0)) * 31;
Item.ContactSyncUpsell contactSyncUpsell = this.contactSyncUpsell;
if (contactSyncUpsell != null) {
i = contactSyncUpsell.hashCode();
}
return hashCode5 + i;
}
public String toString() {
StringBuilder R = a.R("ListSections(suggestionsHeaderItem=");
R.append(this.suggestionsHeaderItem);
R.append(", suggestedFriendItems=");
R.append(this.suggestedFriendItems);
R.append(", pendingHeaderItem=");
R.append(this.pendingHeaderItem);
R.append(", pendingItems=");
R.append(this.pendingItems);
R.append(", friendsItemsWithHeaders=");
R.append(this.friendsItemsWithHeaders);
R.append(", contactSyncUpsell=");
R.append(this.contactSyncUpsell);
R.append(")");
return R.toString();
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class StoreState {
private final Map<Long, ModelApplicationStream> applicationStreams;
private final long channelId;
private final Map<Long, FriendSuggestion> friendSuggestions;
private final Map<Long, Presence> presences;
private final StoreUserRelationships.UserRelationshipsState relationshipsState;
private final boolean showContactSyncIcon;
private final boolean showContactSyncUpsell;
private final Map<Long, User> users;
/* JADX DEBUG: Multi-variable search result rejected for r7v0, resolved type: java.util.Map<java.lang.Long, ? extends com.discord.models.user.User> */
/* JADX DEBUG: Multi-variable search result rejected for r9v0, resolved type: java.util.Map<java.lang.Long, ? extends com.discord.models.domain.ModelApplicationStream> */
/* JADX WARN: Multi-variable type inference failed */
public StoreState(boolean z2, boolean z3, long j, StoreUserRelationships.UserRelationshipsState userRelationshipsState, Map<Long, ? extends User> map, Map<Long, Presence> map2, Map<Long, ? extends ModelApplicationStream> map3, Map<Long, FriendSuggestion> map4) {
m.checkNotNullParameter(userRelationshipsState, "relationshipsState");
m.checkNotNullParameter(map, "users");
m.checkNotNullParameter(map2, "presences");
m.checkNotNullParameter(map3, "applicationStreams");
m.checkNotNullParameter(map4, "friendSuggestions");
this.showContactSyncIcon = z2;
this.showContactSyncUpsell = z3;
this.channelId = j;
this.relationshipsState = userRelationshipsState;
this.users = map;
this.presences = map2;
this.applicationStreams = map3;
this.friendSuggestions = map4;
}
public static /* synthetic */ StoreState copy$default(StoreState storeState, boolean z2, boolean z3, long j, StoreUserRelationships.UserRelationshipsState userRelationshipsState, Map map, Map map2, Map map3, Map map4, int i, Object obj) {
return storeState.copy((i & 1) != 0 ? storeState.showContactSyncIcon : z2, (i & 2) != 0 ? storeState.showContactSyncUpsell : z3, (i & 4) != 0 ? storeState.channelId : j, (i & 8) != 0 ? storeState.relationshipsState : userRelationshipsState, (i & 16) != 0 ? storeState.users : map, (i & 32) != 0 ? storeState.presences : map2, (i & 64) != 0 ? storeState.applicationStreams : map3, (i & 128) != 0 ? storeState.friendSuggestions : map4);
}
public final boolean component1() {
return this.showContactSyncIcon;
}
public final boolean component2() {
return this.showContactSyncUpsell;
}
public final long component3() {
return this.channelId;
}
public final StoreUserRelationships.UserRelationshipsState component4() {
return this.relationshipsState;
}
public final Map<Long, User> component5() {
return this.users;
}
public final Map<Long, Presence> component6() {
return this.presences;
}
public final Map<Long, ModelApplicationStream> component7() {
return this.applicationStreams;
}
public final Map<Long, FriendSuggestion> component8() {
return this.friendSuggestions;
}
public final StoreState copy(boolean z2, boolean z3, long j, StoreUserRelationships.UserRelationshipsState userRelationshipsState, Map<Long, ? extends User> map, Map<Long, Presence> map2, Map<Long, ? extends ModelApplicationStream> map3, Map<Long, FriendSuggestion> map4) {
m.checkNotNullParameter(userRelationshipsState, "relationshipsState");
m.checkNotNullParameter(map, "users");
m.checkNotNullParameter(map2, "presences");
m.checkNotNullParameter(map3, "applicationStreams");
m.checkNotNullParameter(map4, "friendSuggestions");
return new StoreState(z2, z3, j, userRelationshipsState, map, map2, map3, map4);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof StoreState)) {
return false;
}
StoreState storeState = (StoreState) obj;
return this.showContactSyncIcon == storeState.showContactSyncIcon && this.showContactSyncUpsell == storeState.showContactSyncUpsell && this.channelId == storeState.channelId && m.areEqual(this.relationshipsState, storeState.relationshipsState) && m.areEqual(this.users, storeState.users) && m.areEqual(this.presences, storeState.presences) && m.areEqual(this.applicationStreams, storeState.applicationStreams) && m.areEqual(this.friendSuggestions, storeState.friendSuggestions);
}
public final Map<Long, ModelApplicationStream> getApplicationStreams() {
return this.applicationStreams;
}
public final long getChannelId() {
return this.channelId;
}
public final Map<Long, FriendSuggestion> getFriendSuggestions() {
return this.friendSuggestions;
}
public final Map<Long, Presence> getPresences() {
return this.presences;
}
public final StoreUserRelationships.UserRelationshipsState getRelationshipsState() {
return this.relationshipsState;
}
public final boolean getShowContactSyncIcon() {
return this.showContactSyncIcon;
}
public final boolean getShowContactSyncUpsell() {
return this.showContactSyncUpsell;
}
public final Map<Long, User> getUsers() {
return this.users;
}
public int hashCode() {
boolean z2 = this.showContactSyncIcon;
int i = 1;
if (z2) {
z2 = true;
}
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = i2 * 31;
boolean z3 = this.showContactSyncUpsell;
if (!z3) {
i = z3 ? 1 : 0;
}
int a = (b.a(this.channelId) + ((i5 + i) * 31)) * 31;
StoreUserRelationships.UserRelationshipsState userRelationshipsState = this.relationshipsState;
int i6 = 0;
int hashCode = (a + (userRelationshipsState != null ? userRelationshipsState.hashCode() : 0)) * 31;
Map<Long, User> map = this.users;
int hashCode2 = (hashCode + (map != null ? map.hashCode() : 0)) * 31;
Map<Long, Presence> map2 = this.presences;
int hashCode3 = (hashCode2 + (map2 != null ? map2.hashCode() : 0)) * 31;
Map<Long, ModelApplicationStream> map3 = this.applicationStreams;
int hashCode4 = (hashCode3 + (map3 != null ? map3.hashCode() : 0)) * 31;
Map<Long, FriendSuggestion> map4 = this.friendSuggestions;
if (map4 != null) {
i6 = map4.hashCode();
}
return hashCode4 + i6;
}
public String toString() {
StringBuilder R = a.R("StoreState(showContactSyncIcon=");
R.append(this.showContactSyncIcon);
R.append(", showContactSyncUpsell=");
R.append(this.showContactSyncUpsell);
R.append(", channelId=");
R.append(this.channelId);
R.append(", relationshipsState=");
R.append(this.relationshipsState);
R.append(", users=");
R.append(this.users);
R.append(", presences=");
R.append(this.presences);
R.append(", applicationStreams=");
R.append(this.applicationStreams);
R.append(", friendSuggestions=");
return a.L(R, this.friendSuggestions, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static abstract class ViewState {
/* compiled from: FriendsListViewModel.kt */
public static final class Empty extends ViewState {
private final boolean showContactSyncIcon;
public Empty(boolean z2) {
super(null);
this.showContactSyncIcon = z2;
}
public static /* synthetic */ Empty copy$default(Empty empty, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
z2 = empty.showContactSyncIcon;
}
return empty.copy(z2);
}
public final boolean component1() {
return this.showContactSyncIcon;
}
public final Empty copy(boolean z2) {
return new Empty(z2);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof Empty) && this.showContactSyncIcon == ((Empty) obj).showContactSyncIcon;
}
return true;
}
public final boolean getShowContactSyncIcon() {
return this.showContactSyncIcon;
}
public int hashCode() {
boolean z2 = this.showContactSyncIcon;
if (z2) {
return 1;
}
return z2 ? 1 : 0;
}
public String toString() {
return a.M(a.R("Empty(showContactSyncIcon="), this.showContactSyncIcon, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class Loaded extends ViewState {
private final List<Item> items;
private final boolean showContactSyncIcon;
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: java.util.List<? extends com.discord.widgets.friends.FriendsListViewModel$Item> */
/* JADX WARN: Multi-variable type inference failed */
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Loaded(boolean z2, List<? extends Item> list) {
super(null);
m.checkNotNullParameter(list, "items");
this.showContactSyncIcon = z2;
this.items = list;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.friends.FriendsListViewModel$ViewState$Loaded */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Loaded copy$default(Loaded loaded, boolean z2, List list, int i, Object obj) {
if ((i & 1) != 0) {
z2 = loaded.showContactSyncIcon;
}
if ((i & 2) != 0) {
list = loaded.items;
}
return loaded.copy(z2, list);
}
public final boolean component1() {
return this.showContactSyncIcon;
}
public final List<Item> component2() {
return this.items;
}
public final Loaded copy(boolean z2, List<? extends Item> list) {
m.checkNotNullParameter(list, "items");
return new Loaded(z2, list);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Loaded)) {
return false;
}
Loaded loaded = (Loaded) obj;
return this.showContactSyncIcon == loaded.showContactSyncIcon && m.areEqual(this.items, loaded.items);
}
public final List<Item> getItems() {
return this.items;
}
public final boolean getShowContactSyncIcon() {
return this.showContactSyncIcon;
}
public int hashCode() {
boolean z2 = this.showContactSyncIcon;
if (z2) {
z2 = true;
}
int i = z2 ? 1 : 0;
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = i * 31;
List<Item> list = this.items;
return i4 + (list != null ? list.hashCode() : 0);
}
public String toString() {
StringBuilder R = a.R("Loaded(showContactSyncIcon=");
R.append(this.showContactSyncIcon);
R.append(", items=");
return a.K(R, this.items, ")");
}
}
/* compiled from: FriendsListViewModel.kt */
public static final class Uninitialized extends ViewState {
public static final Uninitialized INSTANCE = new Uninitialized();
private Uninitialized() {
super(null);
}
}
private ViewState() {
}
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public FriendsListViewModel() {
this(null, null, null, 7, null);
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public FriendsListViewModel(Observable<StoreState> observable, StoreChannels storeChannels, RestAPI restAPI) {
super(ViewState.Uninitialized.INSTANCE);
m.checkNotNullParameter(observable, "storeObservable");
m.checkNotNullParameter(storeChannels, "storeChannels");
m.checkNotNullParameter(restAPI, "restAPI");
this.storeObservable = observable;
this.storeChannels = storeChannels;
this.restAPI = restAPI;
this.listSections = new ListSections(null, n.emptyList(), null, n.emptyList(), n.emptyList(), null);
this.eventSubject = PublishSubject.k0();
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(observable, this, null, 2, null), FriendsListViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ FriendsListViewModel(Observable observable, StoreChannels storeChannels, RestAPI restAPI, int i, DefaultConstructorMarker defaultConstructorMarker) {
this((i & 1) != 0 ? Companion.observeStores() : observable, (i & 2) != 0 ? StoreStream.Companion.getChannels() : storeChannels, (i & 4) != 0 ? RestAPI.Companion.getApi() : restAPI);
}
public static /* synthetic */ void acceptFriendSuggestion$default(FriendsListViewModel friendsListViewModel, String str, int i, CaptchaHelper.CaptchaPayload captchaPayload, int i2, Object obj) {
if ((i2 & 4) != 0) {
captchaPayload = null;
}
friendsListViewModel.acceptFriendSuggestion(str, i, captchaPayload);
}
public static final /* synthetic */ void access$emitCaptchaErrorEvent(FriendsListViewModel friendsListViewModel, Error error, String str, int i) {
friendsListViewModel.emitCaptchaErrorEvent(error, str, i);
}
public static final /* synthetic */ void access$emitLaunchVoiceCallEvent(FriendsListViewModel friendsListViewModel, long j) {
friendsListViewModel.emitLaunchVoiceCallEvent(j);
}
public static final /* synthetic */ void access$emitShowFriendRequestAbortToast(FriendsListViewModel friendsListViewModel, int i, String str) {
friendsListViewModel.emitShowFriendRequestAbortToast(i, str);
}
public static final /* synthetic */ void access$emitShowToastEvent(FriendsListViewModel friendsListViewModel, int i) {
friendsListViewModel.emitShowToastEvent(i);
}
public static final /* synthetic */ ListSections access$getItems(FriendsListViewModel friendsListViewModel, Map map, Map map2, Map map3, Map map4, boolean z2, Map map5) {
return friendsListViewModel.getItems(map, map2, map3, map4, z2, map5);
}
public static final /* synthetic */ void access$handleComputedItems(FriendsListViewModel friendsListViewModel, ListSections listSections, boolean z2) {
friendsListViewModel.handleComputedItems(listSections, z2);
}
public static final /* synthetic */ void access$handleStoreState(FriendsListViewModel friendsListViewModel, StoreState storeState) {
friendsListViewModel.handleStoreState(storeState);
}
private final <T> Cancellable asyncComputeAndHandleOnUiThread(Function0<? extends T> function0, Function1<? super Error, Unit> function1, Function1<? super T, Unit> function12) {
Ref$ObjectRef ref$ObjectRef = new Ref$ObjectRef();
ref$ObjectRef.element = null;
Observable<T> X = Observable.n(new FriendsListViewModel$asyncComputeAndHandleOnUiThread$1(function0), Emitter.BackpressureMode.NONE).X(j0.p.a.a());
m.checkNotNullExpressionValue(X, "Observable\n .crea…Schedulers.computation())");
Observable ui$default = ObservableExtensionsKt.ui$default(X, this, null, 2, null);
FriendsListViewModel$asyncComputeAndHandleOnUiThread$2 friendsListViewModel$asyncComputeAndHandleOnUiThread$2 = new FriendsListViewModel$asyncComputeAndHandleOnUiThread$2(function12);
ObservableExtensionsKt.appSubscribe$default(ui$default, FriendsListViewModel.class, (Context) null, new FriendsListViewModel$asyncComputeAndHandleOnUiThread$4(ref$ObjectRef), new FriendsListViewModel$asyncComputeAndHandleOnUiThread$3(function1), (Function0) null, (Function0) null, friendsListViewModel$asyncComputeAndHandleOnUiThread$2, 50, (Object) null);
return new FriendsListViewModel$asyncComputeAndHandleOnUiThread$5(ref$ObjectRef);
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.friends.FriendsListViewModel */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Cancellable asyncComputeAndHandleOnUiThread$default(FriendsListViewModel friendsListViewModel, Function0 function0, Function1 function1, Function1 function12, int i, Object obj) {
if ((i & 2) != 0) {
function1 = null;
}
return friendsListViewModel.asyncComputeAndHandleOnUiThread(function0, function1, function12);
}
private final void emitCaptchaErrorEvent(Error error, String str, int i) {
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.k.onNext(new Event.CaptchaError(error, str, i));
}
private final void emitLaunchVoiceCallEvent(long j) {
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.k.onNext(new Event.LaunchVoiceCall(j));
}
private final void emitShowFriendRequestAbortToast(int i, String str) {
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.k.onNext(new Event.ShowFriendRequestErrorToast(i, str));
}
private final void emitShowToastEvent(@StringRes int i) {
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.k.onNext(new Event.ShowToast(i));
}
@MainThread
private final void generateLoadedItems(boolean z2) {
Item.SuggestedFriendsHeader suggestionsHeaderItem = this.listSections.getSuggestionsHeaderItem();
Item.PendingHeader pendingHeader = null;
Item.SuggestedFriendsHeader copy$default = suggestionsHeaderItem != null ? Item.SuggestedFriendsHeader.copy$default(suggestionsHeaderItem, 0, this.isSuggestedSectionExpanded, false, 5, null) : null;
Item.PendingHeader pendingHeaderItem = this.listSections.getPendingHeaderItem();
if (pendingHeaderItem != null) {
pendingHeader = Item.PendingHeader.copy$default(pendingHeaderItem, 0, 0, this.isPendingSectionExpanded, false, 11, null);
}
ListSections copy$default2 = ListSections.copy$default(this.listSections, copy$default, null, pendingHeader, null, null, null, 58, null);
this.listSections = copy$default2;
List<Item> visibleItems = getVisibleItems(copy$default2);
updateViewState(visibleItems.isEmpty() ^ true ? new ViewState.Loaded(z2, visibleItems) : new ViewState.Empty(z2));
}
public static /* synthetic */ void generateLoadedItems$default(FriendsListViewModel friendsListViewModel, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
z2 = false;
}
friendsListViewModel.generateLoadedItems(z2);
}
private final ListSections getItems(Map<Long, Integer> map, Map<Long, ? extends User> map2, Map<Long, Presence> map3, Map<Long, ? extends ModelApplicationStream> map4, boolean z2, Map<Long, FriendSuggestion> map5) {
ArrayList arrayList = new ArrayList();
if (!map5.isEmpty()) {
for (FriendSuggestion friendSuggestion : map5.values()) {
arrayList.add(new Item.SuggestedFriend(friendSuggestion));
}
if (arrayList.size() > 1) {
q.sortWith(arrayList, new FriendsListViewModel$getItems$$inlined$sortBy$1());
}
}
Item.SuggestedFriendsHeader suggestedFriendsHeader = !arrayList.isEmpty() ? new Item.SuggestedFriendsHeader(arrayList.size(), false, arrayList.size() > 2) : null;
FriendsListViewModel$getItems$3 friendsListViewModel$getItems$3 = FriendsListViewModel$getItems$3.INSTANCE;
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
for (Map.Entry entry : i0.asSequence(map)) {
long longValue = ((Number) entry.getKey()).longValue();
int intValue = ((Number) entry.getValue()).intValue();
User user = (User) map2.get(Long.valueOf(longValue));
int type = ModelUserRelationship.getType(Integer.valueOf(intValue));
Presence presence = map3.get(Long.valueOf(longValue));
boolean containsKey = map4.containsKey(Long.valueOf(longValue));
if (!(user == null || type == 2)) {
if (FriendsListViewModel$getItems$3.INSTANCE.invoke(type)) {
arrayList2.add(new Item.PendingFriendRequest(user, presence, type));
} else {
arrayList3.add(new Item.Friend(user, presence, containsKey));
}
}
}
List list = u.toList(u.sortedWith(arrayList2, FriendsListViewModel$getItems$sortedPendingItems$1.INSTANCE));
Item.PendingHeader pendingHeader = !list.isEmpty() ? new Item.PendingHeader(R.string.friends_pending_request_header, list.size(), false, list.size() > 2) : null;
ArrayList arrayList4 = new ArrayList();
ArrayList arrayList5 = new ArrayList();
for (Object obj : arrayList3) {
if (((Item.Friend) obj).isOnline()) {
arrayList5.add(obj);
}
}
List list2 = u.toList(u.sortedWith(arrayList5, FriendsListViewModel$getItems$onlineFriendItems$2.INSTANCE));
if (!list2.isEmpty()) {
arrayList4.add(new Item.Header(R.string.friends_online_header, list2.size()));
arrayList4.addAll(list2);
}
ArrayList arrayList6 = new ArrayList();
for (Object obj2 : arrayList3) {
if (!((Item.Friend) obj2).isOnline()) {
arrayList6.add(obj2);
}
}
List list3 = u.toList(u.sortedWith(arrayList6, FriendsListViewModel$getItems$offlineFriendItems$2.INSTANCE));
if (true ^ list3.isEmpty()) {
arrayList4.add(new Item.Header(R.string.friends_offline_header, list3.size()));
arrayList4.addAll(list3);
}
return new ListSections(suggestedFriendsHeader, arrayList, pendingHeader, list, arrayList4, z2 ? new Item.ContactSyncUpsell(false) : null);
}
private final List<Item> getVisibleItems(ListSections listSections) {
Item.SuggestedFriendsHeader suggestionsHeaderItem = listSections.getSuggestionsHeaderItem();
List<Item.SuggestedFriend> suggestedFriendItems = listSections.getSuggestedFriendItems();
Item.PendingHeader pendingHeaderItem = listSections.getPendingHeaderItem();
List<Item> pendingItems = listSections.getPendingItems();
List<Item> friendsItemsWithHeaders = listSections.getFriendsItemsWithHeaders();
ArrayList arrayList = new ArrayList();
if (listSections.getContactSyncUpsell() != null) {
arrayList.add(listSections.getContactSyncUpsell());
}
if (!this.isSuggestedSectionExpanded) {
suggestedFriendItems = u.take(suggestedFriendItems, 2);
}
if (suggestionsHeaderItem != null && (!suggestedFriendItems.isEmpty())) {
arrayList.add(suggestionsHeaderItem);
arrayList.addAll(suggestedFriendItems);
}
if (!this.isPendingSectionExpanded) {
pendingItems = u.take(pendingItems, 2);
}
if (pendingHeaderItem != null && (!pendingItems.isEmpty())) {
arrayList.add(pendingHeaderItem);
arrayList.addAll(pendingItems);
}
arrayList.addAll(friendsItemsWithHeaders);
return arrayList;
}
@MainThread
private final void handleComputedItems(ListSections listSections, boolean z2) {
this.listSections = listSections;
generateLoadedItems(z2);
}
private final void handleStoreState(StoreState storeState) {
Cancellable cancellable = this.computeItemJob;
if (cancellable != null) {
cancellable.cancel();
}
if (storeState.getRelationshipsState() instanceof StoreUserRelationships.UserRelationshipsState.Loaded) {
Map<Long, Integer> relationships = ((StoreUserRelationships.UserRelationshipsState.Loaded) storeState.getRelationshipsState()).getRelationships();
if (relationships.isEmpty()) {
updateViewState(new ViewState.Empty(storeState.getShowContactSyncIcon() || storeState.getShowContactSyncUpsell()));
} else {
this.computeItemJob = asyncComputeAndHandleOnUiThread$default(this, new FriendsListViewModel$handleStoreState$1(this, relationships, storeState), null, new FriendsListViewModel$handleStoreState$2(this, storeState), 2, null);
}
} else {
updateViewState(ViewState.Uninitialized.INSTANCE);
}
}
public final void acceptFriendRequest(long j, String str) {
m.checkNotNullParameter(str, "username");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.addRelationship$default(this.restAPI, LOCATION, j, null, null, null, 28, null), false, 1, null), this, null, 2, null), FriendsListViewModel.class, (Context) null, (Function1) null, new FriendsListViewModel$acceptFriendRequest$2(this, str), (Function0) null, (Function0) null, new FriendsListViewModel$acceptFriendRequest$1(this), 54, (Object) null);
}
public final void acceptFriendSuggestion(String str, int i, CaptchaHelper.CaptchaPayload captchaPayload) {
m.checkNotNullParameter(str, "username");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().sendRelationshipRequest("Friends List - Friend Suggestion", str, i, captchaPayload), false, 1, null), this, null, 2, null), FriendsListViewModel.class, (Context) null, (Function1) null, new FriendsListViewModel$acceptFriendSuggestion$2(this, str, i), (Function0) null, (Function0) null, FriendsListViewModel$acceptFriendSuggestion$1.INSTANCE, 54, (Object) null);
}
@MainThread
public final void dismissContactSyncUpsell() {
StoreStream.Companion.getContactSync().dismissFriendsListUpsell();
}
public final RestAPI getRestAPI() {
return this.restAPI;
}
public final StoreChannels getStoreChannels() {
return this.storeChannels;
}
public final Observable<StoreState> getStoreObservable() {
return this.storeObservable;
}
@MainThread
public final void handleClickPendingHeader() {
this.isPendingSectionExpanded = !this.isPendingSectionExpanded;
ViewState viewState = getViewState();
generateLoadedItems(viewState instanceof ViewState.Empty ? ((ViewState.Empty) viewState).getShowContactSyncIcon() : viewState instanceof ViewState.Loaded ? ((ViewState.Loaded) viewState).getShowContactSyncIcon() : false);
}
@MainThread
public final void handleClickSuggestedHeader() {
this.isSuggestedSectionExpanded = !this.isSuggestedSectionExpanded;
ViewState viewState = getViewState();
generateLoadedItems(viewState instanceof ViewState.Empty ? ((ViewState.Empty) viewState).getShowContactSyncIcon() : viewState instanceof ViewState.Loaded ? ((ViewState.Loaded) viewState).getShowContactSyncIcon() : false);
}
public final void ignoreSuggestion(long j) {
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(this.restAPI.ignoreFriendSuggestion(j), false, 1, null), this, null, 2, null), FriendsListViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, FriendsListViewModel$ignoreSuggestion$1.INSTANCE, 62, (Object) null);
}
public final void launchVoiceCall(long j) {
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(this.restAPI.createOrFetchDM(j), false, 1, null), this, null, 2, null), FriendsListViewModel.class, (Context) null, (Function1) null, new FriendsListViewModel$launchVoiceCall$2(this), (Function0) null, (Function0) null, new FriendsListViewModel$launchVoiceCall$1(this), 54, (Object) null);
}
@MainThread
public final Observable<Event> observeEvents() {
PublishSubject<Event> publishSubject = this.eventSubject;
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
return publishSubject;
}
public final void removeFriendRequest(long j, int i) {
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(this.restAPI.removeRelationship(LOCATION, j), false, 1, null), this, null, 2, null), FriendsListViewModel.class, (Context) null, (Function1) null, new FriendsListViewModel$removeFriendRequest$2(this), (Function0) null, (Function0) null, new FriendsListViewModel$removeFriendRequest$1(this, i == 3 ? R.string.friend_request_ignored : R.string.friend_request_cancelled), 54, (Object) null);
}
}