forked from Juby210/discord-jadx
317 lines
16 KiB
Java
317 lines
16 KiB
Java
package com.discord.widgets.guildscheduledevent;
|
|
|
|
import c.d.b.a.a;
|
|
import c0.z.d.m;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEventEntityMetadata;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEventEntityType;
|
|
import com.discord.api.utcdatetime.UtcDateTime;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
import com.discord.stores.StoreGuildScheduledEvents;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import kotlin.Pair;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: GuildScheduledEventSettingsViewModel.kt */
|
|
public final class GuildScheduledEventSettingsViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final int SAMPLE_USER_COUNT = 1;
|
|
|
|
/* compiled from: GuildScheduledEventSettingsViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventSettingsViewModel.kt */
|
|
public enum DateError {
|
|
INVALID_VIEW_STATE,
|
|
START_DATE_IN_PAST,
|
|
END_DATE_IN_PAST,
|
|
END_DATE_BEFORE_START_DATE
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventSettingsViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: GuildScheduledEventSettingsViewModel.kt */
|
|
public static final class Initialized extends ViewState {
|
|
private final GuildScheduledEventModel eventModel;
|
|
private final GuildScheduledEvent existingEvent;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Initialized(GuildScheduledEventModel guildScheduledEventModel, GuildScheduledEvent guildScheduledEvent) {
|
|
super(null);
|
|
m.checkNotNullParameter(guildScheduledEventModel, "eventModel");
|
|
this.eventModel = guildScheduledEventModel;
|
|
this.existingEvent = guildScheduledEvent;
|
|
}
|
|
|
|
public static /* synthetic */ Initialized copy$default(Initialized initialized, GuildScheduledEventModel guildScheduledEventModel, GuildScheduledEvent guildScheduledEvent, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guildScheduledEventModel = initialized.eventModel;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
guildScheduledEvent = initialized.existingEvent;
|
|
}
|
|
return initialized.copy(guildScheduledEventModel, guildScheduledEvent);
|
|
}
|
|
|
|
public final GuildScheduledEventModel component1() {
|
|
return this.eventModel;
|
|
}
|
|
|
|
public final GuildScheduledEvent component2() {
|
|
return this.existingEvent;
|
|
}
|
|
|
|
public final Initialized copy(GuildScheduledEventModel guildScheduledEventModel, GuildScheduledEvent guildScheduledEvent) {
|
|
m.checkNotNullParameter(guildScheduledEventModel, "eventModel");
|
|
return new Initialized(guildScheduledEventModel, guildScheduledEvent);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Initialized)) {
|
|
return false;
|
|
}
|
|
Initialized initialized = (Initialized) obj;
|
|
return m.areEqual(this.eventModel, initialized.eventModel) && m.areEqual(this.existingEvent, initialized.existingEvent);
|
|
}
|
|
|
|
public final GuildScheduledEventModel getEventModel() {
|
|
return this.eventModel;
|
|
}
|
|
|
|
public final GuildScheduledEvent getExistingEvent() {
|
|
return this.existingEvent;
|
|
}
|
|
|
|
public int hashCode() {
|
|
GuildScheduledEventModel guildScheduledEventModel = this.eventModel;
|
|
int i = 0;
|
|
int hashCode = (guildScheduledEventModel != null ? guildScheduledEventModel.hashCode() : 0) * 31;
|
|
GuildScheduledEvent guildScheduledEvent = this.existingEvent;
|
|
if (guildScheduledEvent != null) {
|
|
i = guildScheduledEvent.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder O = a.O("Initialized(eventModel=");
|
|
O.append(this.eventModel);
|
|
O.append(", existingEvent=");
|
|
O.append(this.existingEvent);
|
|
O.append(")");
|
|
return O.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventSettingsViewModel.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 GuildScheduledEventSettingsViewModel(long j, Long l, GuildScheduledEventEntityType guildScheduledEventEntityType, Long l2, String str, StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
super(null, 1, null);
|
|
GuildScheduledEvent guildScheduledEvent;
|
|
int i;
|
|
GuildScheduledEventEntityType guildScheduledEventEntityType2;
|
|
GuildScheduledEventModel model;
|
|
m.checkNotNullParameter(guildScheduledEventEntityType, "entityType");
|
|
m.checkNotNullParameter(storeGuildScheduledEvents, "guildScheduledEventsStore");
|
|
GuildScheduledEventModel guildScheduledEventModel = null;
|
|
GuildScheduledEvent findEventFromStore = l != null ? storeGuildScheduledEvents.findEventFromStore(l.longValue(), Long.valueOf(j)) : null;
|
|
if (findEventFromStore == null || (model = GuildScheduledEventModelKt.toModel(findEventFromStore)) == null) {
|
|
guildScheduledEvent = findEventFromStore;
|
|
guildScheduledEventEntityType2 = guildScheduledEventEntityType;
|
|
i = 1;
|
|
} else {
|
|
guildScheduledEvent = findEventFromStore;
|
|
i = 1;
|
|
guildScheduledEventEntityType2 = guildScheduledEventEntityType;
|
|
guildScheduledEventModel = GuildScheduledEventModel.copy$default(model, 0, null, l2, null, null, null, null, null, guildScheduledEventEntityType, GuildScheduledEventEntityMetadata.Companion.a(guildScheduledEventEntityType, str), null, 1275, null);
|
|
}
|
|
Pair<GuildScheduledEventPickerDate, GuildScheduledEventPickerTime> generateAppropriateStartDateTime = GuildScheduledEventPickerDateTime.INSTANCE.generateAppropriateStartDateTime();
|
|
updateViewState(new ViewState.Initialized(guildScheduledEventModel == null ? new GuildScheduledEventModel(j, null, l2, generateAppropriateStartDateTime.getFirst(), generateAppropriateStartDateTime.getSecond(), null, null, null, guildScheduledEventEntityType, GuildScheduledEventEntityMetadata.Companion.a(guildScheduledEventEntityType2, str), Integer.valueOf(i)) : guildScheduledEventModel, guildScheduledEvent));
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ GuildScheduledEventSettingsViewModel(long j, Long l, GuildScheduledEventEntityType guildScheduledEventEntityType, Long l2, String str, StoreGuildScheduledEvents storeGuildScheduledEvents, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, l, guildScheduledEventEntityType, l2, str, (i & 32) != 0 ? StoreStream.Companion.getGuildScheduledEvents() : storeGuildScheduledEvents);
|
|
}
|
|
|
|
private final Unit updateEventModel(GuildScheduledEventModel guildScheduledEventModel) {
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized == null) {
|
|
return null;
|
|
}
|
|
updateViewState(ViewState.Initialized.copy$default(initialized, guildScheduledEventModel, null, 2, null));
|
|
return Unit.a;
|
|
}
|
|
|
|
public final boolean hasEndTimeChanged(ViewState.Initialized initialized) {
|
|
m.checkNotNullParameter(initialized, "viewState");
|
|
if (initialized.getExistingEvent() == null) {
|
|
return true;
|
|
}
|
|
if (initialized.getEventModel().getEndDate() == null || initialized.getEventModel().getEndTime() == null) {
|
|
return initialized.getExistingEvent().i() == null;
|
|
}
|
|
long millis = GuildScheduledEventPickerDateTime.INSTANCE.toMillis(initialized.getEventModel().getEndDate(), initialized.getEventModel().getEndTime());
|
|
UtcDateTime i = initialized.getExistingEvent().i();
|
|
Long valueOf = i != null ? Long.valueOf(i.g()) : null;
|
|
return valueOf == null || millis != valueOf.longValue();
|
|
}
|
|
|
|
public final boolean hasStartTimeChanged(ViewState.Initialized initialized) {
|
|
m.checkNotNullParameter(initialized, "viewState");
|
|
return initialized.getExistingEvent() == null || GuildScheduledEventPickerDateTime.INSTANCE.toMillis(initialized.getEventModel().getStartDate(), initialized.getEventModel().getStartTime()) != initialized.getExistingEvent().j().g();
|
|
}
|
|
|
|
public final boolean isDateInFuture(GuildScheduledEventPickerDate guildScheduledEventPickerDate, GuildScheduledEventPickerTime guildScheduledEventPickerTime) {
|
|
return guildScheduledEventPickerDate == null || guildScheduledEventPickerTime == null || GuildScheduledEventPickerDateTime.INSTANCE.toMillis(guildScheduledEventPickerDate, guildScheduledEventPickerTime) >= ClockFactory.get().currentTimeMillis();
|
|
}
|
|
|
|
public final boolean isNextButtonEnabled() {
|
|
GuildScheduledEventModel eventModel;
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized == null || (eventModel = initialized.getEventModel()) == null) {
|
|
return false;
|
|
}
|
|
String name = eventModel.getName();
|
|
if (name == null || name.length() == 0) {
|
|
return false;
|
|
}
|
|
return (eventModel.getEntityType() == GuildScheduledEventEntityType.EXTERNAL && (eventModel.getEndDate() == null || eventModel.getEndTime() == null)) ? false : true;
|
|
}
|
|
|
|
public final boolean isStartDateBeforeEndDate(GuildScheduledEventPickerDate guildScheduledEventPickerDate, GuildScheduledEventPickerTime guildScheduledEventPickerTime, GuildScheduledEventPickerDate guildScheduledEventPickerDate2, GuildScheduledEventPickerTime guildScheduledEventPickerTime2) {
|
|
m.checkNotNullParameter(guildScheduledEventPickerDate, "startDate");
|
|
m.checkNotNullParameter(guildScheduledEventPickerTime, "startTime");
|
|
if (guildScheduledEventPickerDate2 == null || guildScheduledEventPickerTime2 == null) {
|
|
return guildScheduledEventPickerDate2 == null || guildScheduledEventPickerDate2.toMillis() >= guildScheduledEventPickerDate.toMillis();
|
|
}
|
|
GuildScheduledEventPickerDateTime guildScheduledEventPickerDateTime = GuildScheduledEventPickerDateTime.INSTANCE;
|
|
return guildScheduledEventPickerDateTime.toMillis(guildScheduledEventPickerDate2, guildScheduledEventPickerTime2) > guildScheduledEventPickerDateTime.toMillis(guildScheduledEventPickerDate, guildScheduledEventPickerTime);
|
|
}
|
|
|
|
public final boolean isStartDateBeforeEndDate(ViewState.Initialized initialized) {
|
|
m.checkNotNullParameter(initialized, "viewState");
|
|
return isStartDateBeforeEndDate(initialized.getEventModel().getStartDate(), initialized.getEventModel().getStartTime(), initialized.getEventModel().getEndDate(), initialized.getEventModel().getEndTime());
|
|
}
|
|
|
|
public final Unit setDescription(String str) {
|
|
GuildScheduledEventModel eventModel;
|
|
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_DESCRIPTION);
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized == null || (eventModel = initialized.getEventModel()) == null) {
|
|
return null;
|
|
}
|
|
return updateEventModel(GuildScheduledEventModel.copy$default(eventModel, 0, null, null, null, null, null, null, str, null, null, null, 1919, null));
|
|
}
|
|
|
|
public final DateError setEndDate(int i, int i2, int i3) {
|
|
GuildScheduledEventModel eventModel;
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized == null || (eventModel = initialized.getEventModel()) == null) {
|
|
return DateError.INVALID_VIEW_STATE;
|
|
}
|
|
updateEventModel(GuildScheduledEventModel.copy$default(eventModel, 0, null, null, null, null, new GuildScheduledEventPickerDate(i, i2, i3), null, null, null, null, null, 2015, null));
|
|
return null;
|
|
}
|
|
|
|
public final DateError setEndTime(int i, int i2) {
|
|
GuildScheduledEventModel eventModel;
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized == null || (eventModel = initialized.getEventModel()) == null) {
|
|
return DateError.INVALID_VIEW_STATE;
|
|
}
|
|
updateEventModel(GuildScheduledEventModel.copy$default(eventModel, 0, null, null, null, null, null, new GuildScheduledEventPickerTime(i, i2, 0), null, null, null, null, 1983, null));
|
|
return null;
|
|
}
|
|
|
|
public final DateError setStartDate(int i, int i2, int i3) {
|
|
GuildScheduledEventModel eventModel;
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized == null || (eventModel = initialized.getEventModel()) == null) {
|
|
return DateError.INVALID_VIEW_STATE;
|
|
}
|
|
updateEventModel(GuildScheduledEventModel.copy$default(eventModel, 0, null, null, new GuildScheduledEventPickerDate(i, i2, i3), null, null, null, null, null, null, null, 2039, null));
|
|
return null;
|
|
}
|
|
|
|
public final DateError setStartTime(int i, int i2) {
|
|
GuildScheduledEventModel eventModel;
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized == null || (eventModel = initialized.getEventModel()) == null) {
|
|
return DateError.INVALID_VIEW_STATE;
|
|
}
|
|
updateEventModel(GuildScheduledEventModel.copy$default(eventModel, 0, null, null, null, new GuildScheduledEventPickerTime(i, i2, 0), null, null, null, null, null, null, 2031, null));
|
|
return null;
|
|
}
|
|
|
|
public final Unit setTopic(String str) {
|
|
GuildScheduledEventModel eventModel;
|
|
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_TOPIC);
|
|
ViewState viewState = getViewState();
|
|
if (!(viewState instanceof ViewState.Initialized)) {
|
|
viewState = null;
|
|
}
|
|
ViewState.Initialized initialized = (ViewState.Initialized) viewState;
|
|
if (initialized == null || (eventModel = initialized.getEventModel()) == null) {
|
|
return null;
|
|
}
|
|
return updateEventModel(GuildScheduledEventModel.copy$default(eventModel, 0, str, null, null, null, null, null, null, null, null, null, 2045, null));
|
|
}
|
|
}
|