forked from Juby210/discord-jadx
384 lines
15 KiB
Java
384 lines
15 KiB
Java
package com.discord.widgets.guilds.contextmenu;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.MainThread;
|
|
import b.d.b.a.a;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.domain.ModelGuildFolder;
|
|
import com.discord.stores.StoreReadStates;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUserSettings;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import d0.t.n;
|
|
import d0.t.n0;
|
|
import d0.t.o;
|
|
import d0.t.u;
|
|
import d0.z.d.k;
|
|
import d0.z.d.m;
|
|
import j0.l.a.q;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
import rx.subjects.PublishSubject;
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public final class FolderContextMenuViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final PublishSubject<Event> eventSubject;
|
|
private final long folderId;
|
|
private List<Long> guildIds;
|
|
private final RestAPI restAPI;
|
|
private final Observable<StoreState> storeStateObservable;
|
|
private Set<Long> unreadGuildIds;
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
/* renamed from: com.discord.widgets.guilds.contextmenu.FolderContextMenuViewModel$1 reason: invalid class name */
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<StoreState, Unit> {
|
|
public AnonymousClass1(FolderContextMenuViewModel folderContextMenuViewModel) {
|
|
super(1, folderContextMenuViewModel, FolderContextMenuViewModel.class, "handleStoreState", "handleStoreState(Lcom/discord/widgets/guilds/contextmenu/FolderContextMenuViewModel$StoreState;)V", 0);
|
|
}
|
|
|
|
/* 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, "p1");
|
|
FolderContextMenuViewModel.access$handleStoreState((FolderContextMenuViewModel) this.receiver, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, long j, StoreUserSettings storeUserSettings, StoreReadStates storeReadStates) {
|
|
return companion.observeStoreState(j, storeUserSettings, storeReadStates);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStoreState(long j, StoreUserSettings storeUserSettings, StoreReadStates storeReadStates) {
|
|
Observable<StoreState> j2 = Observable.j(storeUserSettings.observeGuildFolders(), storeReadStates.getUnreadGuildIds(), new FolderContextMenuViewModel$Companion$observeStoreState$1(j));
|
|
m.checkNotNullExpressionValue(j2, "Observable.combineLatest… )\n }\n }");
|
|
return j2;
|
|
}
|
|
}
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static abstract class Event {
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static final class Dismiss extends Event {
|
|
public static final Dismiss INSTANCE = new Dismiss();
|
|
|
|
private Dismiss() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
private Event() {
|
|
}
|
|
|
|
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static abstract class StoreState {
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static final class Invalid extends StoreState {
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
private Invalid() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static final class Valid extends StoreState {
|
|
private final ModelGuildFolder folder;
|
|
private final Set<Long> unreadGuildIds;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Valid(ModelGuildFolder modelGuildFolder, Set<Long> set) {
|
|
super(null);
|
|
m.checkNotNullParameter(modelGuildFolder, "folder");
|
|
m.checkNotNullParameter(set, "unreadGuildIds");
|
|
this.folder = modelGuildFolder;
|
|
this.unreadGuildIds = set;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guilds.contextmenu.FolderContextMenuViewModel$StoreState$Valid */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ Valid copy$default(Valid valid, ModelGuildFolder modelGuildFolder, Set set, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
modelGuildFolder = valid.folder;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
set = valid.unreadGuildIds;
|
|
}
|
|
return valid.copy(modelGuildFolder, set);
|
|
}
|
|
|
|
public final ModelGuildFolder component1() {
|
|
return this.folder;
|
|
}
|
|
|
|
public final Set<Long> component2() {
|
|
return this.unreadGuildIds;
|
|
}
|
|
|
|
public final Valid copy(ModelGuildFolder modelGuildFolder, Set<Long> set) {
|
|
m.checkNotNullParameter(modelGuildFolder, "folder");
|
|
m.checkNotNullParameter(set, "unreadGuildIds");
|
|
return new Valid(modelGuildFolder, set);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Valid)) {
|
|
return false;
|
|
}
|
|
Valid valid = (Valid) obj;
|
|
return m.areEqual(this.folder, valid.folder) && m.areEqual(this.unreadGuildIds, valid.unreadGuildIds);
|
|
}
|
|
|
|
public final ModelGuildFolder getFolder() {
|
|
return this.folder;
|
|
}
|
|
|
|
public final Set<Long> getUnreadGuildIds() {
|
|
return this.unreadGuildIds;
|
|
}
|
|
|
|
public int hashCode() {
|
|
ModelGuildFolder modelGuildFolder = this.folder;
|
|
int i = 0;
|
|
int hashCode = (modelGuildFolder != null ? modelGuildFolder.hashCode() : 0) * 31;
|
|
Set<Long> set = this.unreadGuildIds;
|
|
if (set != null) {
|
|
i = set.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("Valid(folder=");
|
|
R.append(this.folder);
|
|
R.append(", unreadGuildIds=");
|
|
R.append(this.unreadGuildIds);
|
|
R.append(")");
|
|
return R.toString();
|
|
}
|
|
}
|
|
|
|
private StoreState() {
|
|
}
|
|
|
|
public /* synthetic */ StoreState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static final class Invalid extends ViewState {
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
private Invalid() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: FolderContextMenuViewModel.kt */
|
|
public static final class Valid extends ViewState {
|
|
private final ModelGuildFolder folder;
|
|
private final boolean showMarkAsRead;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Valid(ModelGuildFolder modelGuildFolder, boolean z2) {
|
|
super(null);
|
|
m.checkNotNullParameter(modelGuildFolder, "folder");
|
|
this.folder = modelGuildFolder;
|
|
this.showMarkAsRead = z2;
|
|
}
|
|
|
|
public static /* synthetic */ Valid copy$default(Valid valid, ModelGuildFolder modelGuildFolder, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
modelGuildFolder = valid.folder;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z2 = valid.showMarkAsRead;
|
|
}
|
|
return valid.copy(modelGuildFolder, z2);
|
|
}
|
|
|
|
public final ModelGuildFolder component1() {
|
|
return this.folder;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.showMarkAsRead;
|
|
}
|
|
|
|
public final Valid copy(ModelGuildFolder modelGuildFolder, boolean z2) {
|
|
m.checkNotNullParameter(modelGuildFolder, "folder");
|
|
return new Valid(modelGuildFolder, z2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Valid)) {
|
|
return false;
|
|
}
|
|
Valid valid = (Valid) obj;
|
|
return m.areEqual(this.folder, valid.folder) && this.showMarkAsRead == valid.showMarkAsRead;
|
|
}
|
|
|
|
public final ModelGuildFolder getFolder() {
|
|
return this.folder;
|
|
}
|
|
|
|
public final boolean getShowMarkAsRead() {
|
|
return this.showMarkAsRead;
|
|
}
|
|
|
|
public int hashCode() {
|
|
ModelGuildFolder modelGuildFolder = this.folder;
|
|
int hashCode = (modelGuildFolder != null ? modelGuildFolder.hashCode() : 0) * 31;
|
|
boolean z2 = this.showMarkAsRead;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i = z2 ? 1 : 0;
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("Valid(folder=");
|
|
R.append(this.folder);
|
|
R.append(", showMarkAsRead=");
|
|
return a.L(R, this.showMarkAsRead, ")");
|
|
}
|
|
}
|
|
|
|
private ViewState() {
|
|
}
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public FolderContextMenuViewModel(long j, RestAPI restAPI, Observable<StoreState> observable) {
|
|
super(null);
|
|
m.checkNotNullParameter(restAPI, "restAPI");
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
this.folderId = j;
|
|
this.restAPI = restAPI;
|
|
this.storeStateObservable = observable;
|
|
this.eventSubject = PublishSubject.k0();
|
|
this.guildIds = n.emptyList();
|
|
this.unreadGuildIds = n0.emptySet();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(observable, this, null, 2, null), FolderContextMenuViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
}
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public /* synthetic */ FolderContextMenuViewModel(long j, RestAPI restAPI, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, restAPI, observable);
|
|
restAPI = (i & 2) != 0 ? RestAPI.Companion.getApi() : restAPI;
|
|
if ((i & 4) != 0) {
|
|
Companion companion = Companion;
|
|
StoreStream.Companion companion2 = StoreStream.Companion;
|
|
observable = Companion.access$observeStoreState(companion, j, companion2.getUserSettings(), companion2.getReadStates());
|
|
}
|
|
}
|
|
|
|
public static final /* synthetic */ PublishSubject access$getEventSubject$p(FolderContextMenuViewModel folderContextMenuViewModel) {
|
|
return folderContextMenuViewModel.eventSubject;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(FolderContextMenuViewModel folderContextMenuViewModel, StoreState storeState) {
|
|
folderContextMenuViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
@MainThread
|
|
private final void handleStoreState(StoreState storeState) {
|
|
if (storeState instanceof StoreState.Valid) {
|
|
StoreState.Valid valid = (StoreState.Valid) storeState;
|
|
this.guildIds = valid.getFolder().getGuildIds();
|
|
this.unreadGuildIds = valid.getUnreadGuildIds();
|
|
ModelGuildFolder folder = valid.getFolder();
|
|
List<Long> guildIds = valid.getFolder().getGuildIds();
|
|
boolean z2 = false;
|
|
if (!(guildIds instanceof Collection) || !guildIds.isEmpty()) {
|
|
Iterator<T> it = guildIds.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
if (this.unreadGuildIds.contains(Long.valueOf(((Number) it.next()).longValue()))) {
|
|
z2 = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
updateViewState(new ViewState.Valid(folder, z2));
|
|
} else if (m.areEqual(storeState, StoreState.Invalid.INSTANCE)) {
|
|
updateViewState(ViewState.Invalid.INSTANCE);
|
|
}
|
|
}
|
|
|
|
public final Observable<StoreState> getStoreStateObservable() {
|
|
return this.storeStateObservable;
|
|
}
|
|
|
|
public final Observable<Event> observeEvents() {
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
|
|
return publishSubject;
|
|
}
|
|
|
|
public final void onMarkAsReadClicked() {
|
|
Set<Number> intersect = u.intersect(this.guildIds, this.unreadGuildIds);
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(intersect, 10));
|
|
for (Number number : intersect) {
|
|
arrayList.add(ObservableExtensionsKt.restSubscribeOn$default(this.restAPI.ackGuild(number.longValue()), false, 1, null));
|
|
}
|
|
Observable f02 = Observable.G(Observable.h0(new q(arrayList))).f0();
|
|
m.checkNotNullExpressionValue(f02, "Observable\n .merg…tCalls)\n .toList()");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(f02, this, null, 2, null), FolderContextMenuViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new FolderContextMenuViewModel$onMarkAsReadClicked$1(this), 62, (Object) null);
|
|
}
|
|
|
|
public final void onSettingsClicked() {
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
publishSubject.k.onNext(Event.Dismiss.INSTANCE);
|
|
}
|
|
}
|