forked from Juby210/discord-jadx
421 lines
16 KiB
Java
421 lines
16 KiB
Java
package com.discord.widgets.guilds.contextmenu;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import androidx.annotation.MainThread;
|
|
import b.d.b.a.a;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.stores.StoreGuildSelected;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StoreReadStates;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import d0.z.d.k;
|
|
import d0.z.d.m;
|
|
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: GuildContextMenuViewModel.kt */
|
|
public final class GuildContextMenuViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final PublishSubject<Event> eventSubject;
|
|
private final long guildId;
|
|
private final RestAPI restAPI;
|
|
private final Observable<StoreState> storeStateObservable;
|
|
|
|
/* compiled from: GuildContextMenuViewModel.kt */
|
|
/* renamed from: com.discord.widgets.guilds.contextmenu.GuildContextMenuViewModel$1 reason: invalid class name */
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<StoreState, Unit> {
|
|
public AnonymousClass1(GuildContextMenuViewModel guildContextMenuViewModel) {
|
|
super(1, guildContextMenuViewModel, GuildContextMenuViewModel.class, "handleStoreState", "handleStoreState(Lcom/discord/widgets/guilds/contextmenu/GuildContextMenuViewModel$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");
|
|
GuildContextMenuViewModel.access$handleStoreState((GuildContextMenuViewModel) this.receiver, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildContextMenuViewModel.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, StoreGuilds storeGuilds, StoreUser storeUser, StoreReadStates storeReadStates, StoreGuildSelected storeGuildSelected) {
|
|
return companion.observeStoreState(j, storeGuilds, storeUser, storeReadStates, storeGuildSelected);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStoreState(long j, StoreGuilds storeGuilds, StoreUser storeUser, StoreReadStates storeReadStates, StoreGuildSelected storeGuildSelected) {
|
|
Observable<StoreState> h = Observable.h(storeGuilds.observeGuild(j), StoreUser.observeMe$default(storeUser, false, 1, null), storeReadStates.getIsUnread(j), storeGuildSelected.observeSelectedGuildId(), GuildContextMenuViewModel$Companion$observeStoreState$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(h, "Observable.combineLatest… )\n }\n }");
|
|
return h;
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildContextMenuViewModel.kt */
|
|
public static abstract class Event {
|
|
|
|
/* compiled from: GuildContextMenuViewModel.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: GuildContextMenuViewModel.kt */
|
|
public static abstract class StoreState {
|
|
|
|
/* compiled from: GuildContextMenuViewModel.kt */
|
|
public static final class Invalid extends StoreState {
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
private Invalid() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildContextMenuViewModel.kt */
|
|
public static final class Valid extends StoreState {
|
|
private final Guild guild;
|
|
private final boolean isGuildUnread;
|
|
private final long myUserId;
|
|
private final long selectedGuildId;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Valid(Guild guild, long j, boolean z2, long j2) {
|
|
super(null);
|
|
m.checkNotNullParameter(guild, "guild");
|
|
this.guild = guild;
|
|
this.myUserId = j;
|
|
this.isGuildUnread = z2;
|
|
this.selectedGuildId = j2;
|
|
}
|
|
|
|
public static /* synthetic */ Valid copy$default(Valid valid, Guild guild, long j, boolean z2, long j2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guild = valid.guild;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
j = valid.myUserId;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z2 = valid.isGuildUnread;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
j2 = valid.selectedGuildId;
|
|
}
|
|
return valid.copy(guild, j, z2, j2);
|
|
}
|
|
|
|
public final Guild component1() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.myUserId;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.isGuildUnread;
|
|
}
|
|
|
|
public final long component4() {
|
|
return this.selectedGuildId;
|
|
}
|
|
|
|
public final Valid copy(Guild guild, long j, boolean z2, long j2) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
return new Valid(guild, j, z2, j2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Valid)) {
|
|
return false;
|
|
}
|
|
Valid valid = (Valid) obj;
|
|
return m.areEqual(this.guild, valid.guild) && this.myUserId == valid.myUserId && this.isGuildUnread == valid.isGuildUnread && this.selectedGuildId == valid.selectedGuildId;
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final long getMyUserId() {
|
|
return this.myUserId;
|
|
}
|
|
|
|
public final long getSelectedGuildId() {
|
|
return this.selectedGuildId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Guild guild = this.guild;
|
|
int a = (b.a(this.myUserId) + ((guild != null ? guild.hashCode() : 0) * 31)) * 31;
|
|
boolean z2 = this.isGuildUnread;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i = z2 ? 1 : 0;
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
return b.a(this.selectedGuildId) + ((a + i) * 31);
|
|
}
|
|
|
|
public final boolean isGuildUnread() {
|
|
return this.isGuildUnread;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("Valid(guild=");
|
|
R.append(this.guild);
|
|
R.append(", myUserId=");
|
|
R.append(this.myUserId);
|
|
R.append(", isGuildUnread=");
|
|
R.append(this.isGuildUnread);
|
|
R.append(", selectedGuildId=");
|
|
return a.B(R, this.selectedGuildId, ")");
|
|
}
|
|
}
|
|
|
|
private StoreState() {
|
|
}
|
|
|
|
public /* synthetic */ StoreState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildContextMenuViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: GuildContextMenuViewModel.kt */
|
|
public static final class Invalid extends ViewState {
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
private Invalid() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildContextMenuViewModel.kt */
|
|
public static final class Valid extends ViewState {
|
|
private final Guild guild;
|
|
private final boolean isGuildSelected;
|
|
private final boolean showLeaveGuild;
|
|
private final boolean showMarkAsRead;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Valid(Guild guild, boolean z2, boolean z3, boolean z4) {
|
|
super(null);
|
|
m.checkNotNullParameter(guild, "guild");
|
|
this.guild = guild;
|
|
this.showMarkAsRead = z2;
|
|
this.showLeaveGuild = z3;
|
|
this.isGuildSelected = z4;
|
|
}
|
|
|
|
public static /* synthetic */ Valid copy$default(Valid valid, Guild guild, boolean z2, boolean z3, boolean z4, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guild = valid.guild;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z2 = valid.showMarkAsRead;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z3 = valid.showLeaveGuild;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
z4 = valid.isGuildSelected;
|
|
}
|
|
return valid.copy(guild, z2, z3, z4);
|
|
}
|
|
|
|
public final Guild component1() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.showMarkAsRead;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.showLeaveGuild;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.isGuildSelected;
|
|
}
|
|
|
|
public final Valid copy(Guild guild, boolean z2, boolean z3, boolean z4) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
return new Valid(guild, z2, z3, z4);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Valid)) {
|
|
return false;
|
|
}
|
|
Valid valid = (Valid) obj;
|
|
return m.areEqual(this.guild, valid.guild) && this.showMarkAsRead == valid.showMarkAsRead && this.showLeaveGuild == valid.showLeaveGuild && this.isGuildSelected == valid.isGuildSelected;
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final boolean getShowLeaveGuild() {
|
|
return this.showLeaveGuild;
|
|
}
|
|
|
|
public final boolean getShowMarkAsRead() {
|
|
return this.showMarkAsRead;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Guild guild = this.guild;
|
|
int hashCode = (guild != null ? guild.hashCode() : 0) * 31;
|
|
boolean z2 = this.showMarkAsRead;
|
|
int i = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = (hashCode + i2) * 31;
|
|
boolean z3 = this.showLeaveGuild;
|
|
if (z3) {
|
|
z3 = true;
|
|
}
|
|
int i6 = z3 ? 1 : 0;
|
|
int i7 = z3 ? 1 : 0;
|
|
int i8 = z3 ? 1 : 0;
|
|
int i9 = (i5 + i6) * 31;
|
|
boolean z4 = this.isGuildSelected;
|
|
if (!z4) {
|
|
i = z4 ? 1 : 0;
|
|
}
|
|
return i9 + i;
|
|
}
|
|
|
|
public final boolean isGuildSelected() {
|
|
return this.isGuildSelected;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("Valid(guild=");
|
|
R.append(this.guild);
|
|
R.append(", showMarkAsRead=");
|
|
R.append(this.showMarkAsRead);
|
|
R.append(", showLeaveGuild=");
|
|
R.append(this.showLeaveGuild);
|
|
R.append(", isGuildSelected=");
|
|
return a.L(R, this.isGuildSelected, ")");
|
|
}
|
|
}
|
|
|
|
private ViewState() {
|
|
}
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public GuildContextMenuViewModel(long j, RestAPI restAPI, Observable<StoreState> observable) {
|
|
super(null);
|
|
m.checkNotNullParameter(restAPI, "restAPI");
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
this.guildId = j;
|
|
this.restAPI = restAPI;
|
|
this.storeStateObservable = observable;
|
|
this.eventSubject = PublishSubject.k0();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(observable, this, null, 2, null), GuildContextMenuViewModel.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 */ GuildContextMenuViewModel(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.getGuilds(), companion2.getUsers(), companion2.getReadStates(), companion2.getGuildSelected());
|
|
}
|
|
}
|
|
|
|
public static final /* synthetic */ PublishSubject access$getEventSubject$p(GuildContextMenuViewModel guildContextMenuViewModel) {
|
|
return guildContextMenuViewModel.eventSubject;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(GuildContextMenuViewModel guildContextMenuViewModel, StoreState storeState) {
|
|
guildContextMenuViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
@MainThread
|
|
private final void handleStoreState(StoreState storeState) {
|
|
if (storeState instanceof StoreState.Valid) {
|
|
StoreState.Valid valid = (StoreState.Valid) storeState;
|
|
Guild guild = valid.getGuild();
|
|
boolean isGuildUnread = valid.isGuildUnread();
|
|
boolean z2 = true;
|
|
boolean z3 = valid.getGuild().getOwnerId() != valid.getMyUserId();
|
|
if (valid.getSelectedGuildId() != valid.getGuild().getId()) {
|
|
z2 = false;
|
|
}
|
|
updateViewState(new ViewState.Valid(guild, isGuildUnread, z3, 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() {
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(this.restAPI.ackGuild(this.guildId), false, 1, null), this, null, 2, null), GuildContextMenuViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new GuildContextMenuViewModel$onMarkAsReadClicked$1(this), 62, (Object) null);
|
|
}
|
|
}
|