373 lines
16 KiB
Java
373 lines
16 KiB
Java
package com.discord.widgets.guildscheduledevent;
|
|
|
|
import android.content.Context;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreGuildScheduledEvents;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
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;
|
|
/* compiled from: GuildScheduledEventDetailsViewModel.kt */
|
|
public final class GuildScheduledEventDetailsViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final long guildScheduledEventId;
|
|
private final StoreGuildScheduledEvents guildScheduledEventsStore;
|
|
|
|
/* compiled from: GuildScheduledEventDetailsViewModel.kt */
|
|
/* renamed from: com.discord.widgets.guildscheduledevent.GuildScheduledEventDetailsViewModel$1 reason: invalid class name */
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<StoreState, Unit> {
|
|
public AnonymousClass1(GuildScheduledEventDetailsViewModel guildScheduledEventDetailsViewModel) {
|
|
super(1, guildScheduledEventDetailsViewModel, GuildScheduledEventDetailsViewModel.class, "handleStoreState", "handleStoreState(Lcom/discord/widgets/guildscheduledevent/GuildScheduledEventDetailsViewModel$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");
|
|
GuildScheduledEventDetailsViewModel.access$handleStoreState((GuildScheduledEventDetailsViewModel) this.receiver, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventDetailsViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStores(Companion companion, long j, ObservationDeck observationDeck, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreGuilds storeGuilds, StoreChannels storeChannels) {
|
|
return companion.observeStores(j, observationDeck, storeGuildScheduledEvents, storeGuilds, storeChannels);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStores(long j, ObservationDeck observationDeck, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreGuilds storeGuilds, StoreChannels storeChannels) {
|
|
return ObservationDeck.connectRx$default(observationDeck, new ObservationDeck.UpdateSource[]{storeGuildScheduledEvents, storeGuilds, storeChannels}, false, null, null, new GuildScheduledEventDetailsViewModel$Companion$observeStores$1(storeGuildScheduledEvents, j, storeChannels, storeGuilds), 14, null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventDetailsViewModel.kt */
|
|
public static final class StoreState {
|
|
private final Channel channel;
|
|
private final Guild guild;
|
|
private final GuildScheduledEvent guildScheduledEvent;
|
|
private final boolean isRsvped;
|
|
|
|
public StoreState() {
|
|
this(null, null, null, false, 15, null);
|
|
}
|
|
|
|
public StoreState(GuildScheduledEvent guildScheduledEvent, Channel channel, Guild guild, boolean z2) {
|
|
this.guildScheduledEvent = guildScheduledEvent;
|
|
this.channel = channel;
|
|
this.guild = guild;
|
|
this.isRsvped = z2;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ StoreState(GuildScheduledEvent guildScheduledEvent, Channel channel, Guild guild, boolean z2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this((i & 1) != 0 ? null : guildScheduledEvent, (i & 2) != 0 ? null : channel, (i & 4) != 0 ? null : guild, (i & 8) != 0 ? false : z2);
|
|
}
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, GuildScheduledEvent guildScheduledEvent, Channel channel, Guild guild, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guildScheduledEvent = storeState.guildScheduledEvent;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
channel = storeState.channel;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
guild = storeState.guild;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
z2 = storeState.isRsvped;
|
|
}
|
|
return storeState.copy(guildScheduledEvent, channel, guild, z2);
|
|
}
|
|
|
|
public final GuildScheduledEvent component1() {
|
|
return this.guildScheduledEvent;
|
|
}
|
|
|
|
public final Channel component2() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild component3() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.isRsvped;
|
|
}
|
|
|
|
public final StoreState copy(GuildScheduledEvent guildScheduledEvent, Channel channel, Guild guild, boolean z2) {
|
|
return new StoreState(guildScheduledEvent, channel, guild, z2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StoreState)) {
|
|
return false;
|
|
}
|
|
StoreState storeState = (StoreState) obj;
|
|
return m.areEqual(this.guildScheduledEvent, storeState.guildScheduledEvent) && m.areEqual(this.channel, storeState.channel) && m.areEqual(this.guild, storeState.guild) && this.isRsvped == storeState.isRsvped;
|
|
}
|
|
|
|
public final Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final GuildScheduledEvent getGuildScheduledEvent() {
|
|
return this.guildScheduledEvent;
|
|
}
|
|
|
|
public int hashCode() {
|
|
GuildScheduledEvent guildScheduledEvent = this.guildScheduledEvent;
|
|
int i = 0;
|
|
int hashCode = (guildScheduledEvent != null ? guildScheduledEvent.hashCode() : 0) * 31;
|
|
Channel channel = this.channel;
|
|
int hashCode2 = (hashCode + (channel != null ? channel.hashCode() : 0)) * 31;
|
|
Guild guild = this.guild;
|
|
if (guild != null) {
|
|
i = guild.hashCode();
|
|
}
|
|
int i2 = (hashCode2 + i) * 31;
|
|
boolean z2 = this.isRsvped;
|
|
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 isRsvped() {
|
|
return this.isRsvped;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder P = a.P("StoreState(guildScheduledEvent=");
|
|
P.append(this.guildScheduledEvent);
|
|
P.append(", channel=");
|
|
P.append(this.channel);
|
|
P.append(", guild=");
|
|
P.append(this.guild);
|
|
P.append(", isRsvped=");
|
|
return a.L(P, this.isRsvped, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventDetailsViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: GuildScheduledEventDetailsViewModel.kt */
|
|
public static final class Initialized extends ViewState {
|
|
private final Channel channel;
|
|
private final Guild guild;
|
|
private final GuildScheduledEvent guildScheduledEvent;
|
|
private final boolean isRsvped;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Initialized(GuildScheduledEvent guildScheduledEvent, Channel channel, Guild guild, boolean z2) {
|
|
super(null);
|
|
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
|
|
m.checkNotNullParameter(guild, "guild");
|
|
this.guildScheduledEvent = guildScheduledEvent;
|
|
this.channel = channel;
|
|
this.guild = guild;
|
|
this.isRsvped = z2;
|
|
}
|
|
|
|
public static /* synthetic */ Initialized copy$default(Initialized initialized, GuildScheduledEvent guildScheduledEvent, Channel channel, Guild guild, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guildScheduledEvent = initialized.guildScheduledEvent;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
channel = initialized.channel;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
guild = initialized.guild;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
z2 = initialized.isRsvped;
|
|
}
|
|
return initialized.copy(guildScheduledEvent, channel, guild, z2);
|
|
}
|
|
|
|
public final GuildScheduledEvent component1() {
|
|
return this.guildScheduledEvent;
|
|
}
|
|
|
|
public final Channel component2() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild component3() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.isRsvped;
|
|
}
|
|
|
|
public final Initialized copy(GuildScheduledEvent guildScheduledEvent, Channel channel, Guild guild, boolean z2) {
|
|
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
|
|
m.checkNotNullParameter(guild, "guild");
|
|
return new Initialized(guildScheduledEvent, channel, guild, z2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Initialized)) {
|
|
return false;
|
|
}
|
|
Initialized initialized = (Initialized) obj;
|
|
return m.areEqual(this.guildScheduledEvent, initialized.guildScheduledEvent) && m.areEqual(this.channel, initialized.channel) && m.areEqual(this.guild, initialized.guild) && this.isRsvped == initialized.isRsvped;
|
|
}
|
|
|
|
public final Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final GuildScheduledEvent getGuildScheduledEvent() {
|
|
return this.guildScheduledEvent;
|
|
}
|
|
|
|
public int hashCode() {
|
|
GuildScheduledEvent guildScheduledEvent = this.guildScheduledEvent;
|
|
int i = 0;
|
|
int hashCode = (guildScheduledEvent != null ? guildScheduledEvent.hashCode() : 0) * 31;
|
|
Channel channel = this.channel;
|
|
int hashCode2 = (hashCode + (channel != null ? channel.hashCode() : 0)) * 31;
|
|
Guild guild = this.guild;
|
|
if (guild != null) {
|
|
i = guild.hashCode();
|
|
}
|
|
int i2 = (hashCode2 + i) * 31;
|
|
boolean z2 = this.isRsvped;
|
|
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 isRsvped() {
|
|
return this.isRsvped;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder P = a.P("Initialized(guildScheduledEvent=");
|
|
P.append(this.guildScheduledEvent);
|
|
P.append(", channel=");
|
|
P.append(this.channel);
|
|
P.append(", guild=");
|
|
P.append(this.guild);
|
|
P.append(", isRsvped=");
|
|
return a.L(P, this.isRsvped, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventDetailsViewModel.kt */
|
|
public static final class Invalid extends ViewState {
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
private Invalid() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
private ViewState() {
|
|
}
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public GuildScheduledEventDetailsViewModel(long j, ObservationDeck observationDeck, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreGuilds storeGuilds, StoreChannels storeChannels, Observable<StoreState> observable) {
|
|
super(null, 1, null);
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
m.checkNotNullParameter(storeGuildScheduledEvents, "guildScheduledEventsStore");
|
|
m.checkNotNullParameter(storeGuilds, "guildsStore");
|
|
m.checkNotNullParameter(storeChannels, "channelsStore");
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
this.guildScheduledEventId = j;
|
|
this.guildScheduledEventsStore = storeGuildScheduledEvents;
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), GuildScheduledEventDetailsViewModel.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 */ GuildScheduledEventDetailsViewModel(long j, ObservationDeck observationDeck, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreGuilds storeGuilds, StoreChannels storeChannels, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, r4, r5, r6, r7, (i & 32) != 0 ? Companion.access$observeStores(Companion, j, r4, r5, r6, r7) : observable);
|
|
ObservationDeck observationDeck2 = (i & 2) != 0 ? ObservationDeckProvider.get() : observationDeck;
|
|
StoreGuildScheduledEvents guildScheduledEvents = (i & 4) != 0 ? StoreStream.Companion.getGuildScheduledEvents() : storeGuildScheduledEvents;
|
|
StoreGuilds guilds = (i & 8) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds;
|
|
StoreChannels channels = (i & 16) != 0 ? StoreStream.Companion.getChannels() : storeChannels;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(GuildScheduledEventDetailsViewModel guildScheduledEventDetailsViewModel, StoreState storeState) {
|
|
guildScheduledEventDetailsViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
Object obj;
|
|
if (storeState.getGuildScheduledEvent() == null || storeState.getGuild() == null) {
|
|
obj = ViewState.Invalid.INSTANCE;
|
|
} else {
|
|
if (getViewState() == null) {
|
|
this.guildScheduledEventsStore.fetchGuildScheduledEventUserCounts(storeState.getGuild().getId());
|
|
}
|
|
obj = new ViewState.Initialized(storeState.getGuildScheduledEvent(), storeState.getChannel(), storeState.getGuild(), storeState.isRsvped());
|
|
}
|
|
updateViewState(obj);
|
|
}
|
|
|
|
public final void onRsvpButtonClicked() {
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized != null) {
|
|
this.guildScheduledEventsStore.toggleRsvpGuildScheduledEvent(initialized.getGuildScheduledEvent());
|
|
}
|
|
}
|
|
}
|