2021-12-17 22:03:14 +00:00
|
|
|
package com.discord.widgets.guildcommunicationdisabled.start;
|
|
|
|
|
|
|
|
import a0.a.a.b;
|
|
|
|
import android.content.Context;
|
2021-12-21 23:37:30 +00:00
|
|
|
import b.d.b.a.a;
|
2021-12-17 22:03:14 +00:00
|
|
|
import com.discord.app.AppViewModel;
|
|
|
|
import com.discord.models.guild.Guild;
|
|
|
|
import com.discord.models.user.User;
|
|
|
|
import com.discord.restapi.RestAPIParams;
|
|
|
|
import com.discord.stores.StoreGuilds;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.stores.StoreUser;
|
|
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
2022-01-19 20:19:48 +00:00
|
|
|
import com.discord.stores.utilities.RestCallStateKt;
|
2021-12-17 22:03:14 +00:00
|
|
|
import com.discord.utilities.rest.RestAPI;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import d0.z.d.k;
|
|
|
|
import d0.z.d.m;
|
2021-12-21 23:37:30 +00:00
|
|
|
import java.lang.ref.WeakReference;
|
2022-01-19 20:19:48 +00:00
|
|
|
import kotlin.Pair;
|
2021-12-17 22:03:14 +00:00
|
|
|
import kotlin.Unit;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import rx.Observable;
|
|
|
|
/* compiled from: DisableGuildCommunicationViewModel.kt */
|
|
|
|
public final class DisableGuildCommunicationViewModel extends AppViewModel<ViewState> {
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
private final long guildId;
|
|
|
|
private final long userId;
|
|
|
|
|
|
|
|
/* compiled from: DisableGuildCommunicationViewModel.kt */
|
|
|
|
/* renamed from: com.discord.widgets.guildcommunicationdisabled.start.DisableGuildCommunicationViewModel$1 reason: invalid class name */
|
|
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<StoreState, Unit> {
|
|
|
|
public AnonymousClass1(DisableGuildCommunicationViewModel disableGuildCommunicationViewModel) {
|
|
|
|
super(1, disableGuildCommunicationViewModel, DisableGuildCommunicationViewModel.class, "handleStoreState", "handleStoreState(Lcom/discord/widgets/guildcommunicationdisabled/start/DisableGuildCommunicationViewModel$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");
|
|
|
|
DisableGuildCommunicationViewModel.access$handleStoreState((DisableGuildCommunicationViewModel) this.receiver, storeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: DisableGuildCommunicationViewModel.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, long j2, ObservationDeck observationDeck, StoreUser storeUser, StoreGuilds storeGuilds) {
|
|
|
|
return companion.observeStores(j, j2, observationDeck, storeUser, storeGuilds);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final Observable<StoreState> observeStores(long j, long j2, ObservationDeck observationDeck, StoreUser storeUser, StoreGuilds storeGuilds) {
|
|
|
|
return ObservationDeck.connectRx$default(observationDeck, new ObservationDeck.UpdateSource[]{storeUser, storeGuilds}, false, null, null, new DisableGuildCommunicationViewModel$Companion$observeStores$1(storeUser, j, storeGuilds, j2), 14, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: DisableGuildCommunicationViewModel.kt */
|
|
|
|
public static final class StoreState {
|
|
|
|
private final Guild guild;
|
|
|
|
private final User user;
|
|
|
|
|
|
|
|
public StoreState(User user, Guild guild) {
|
|
|
|
this.user = user;
|
|
|
|
this.guild = guild;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, User user, Guild guild, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
user = storeState.user;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
guild = storeState.guild;
|
|
|
|
}
|
|
|
|
return storeState.copy(user, guild);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final User component1() {
|
|
|
|
return this.user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Guild component2() {
|
|
|
|
return this.guild;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final StoreState copy(User user, Guild guild) {
|
|
|
|
return new StoreState(user, guild);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof StoreState)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
StoreState storeState = (StoreState) obj;
|
|
|
|
return m.areEqual(this.user, storeState.user) && m.areEqual(this.guild, storeState.guild);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Guild getGuild() {
|
|
|
|
return this.guild;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
Guild guild = this.guild;
|
|
|
|
if (guild != null) {
|
|
|
|
i = guild.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder R = a.R("StoreState(user=");
|
|
|
|
R.append(this.user);
|
|
|
|
R.append(", guild=");
|
|
|
|
R.append(this.guild);
|
|
|
|
R.append(")");
|
|
|
|
return R.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: DisableGuildCommunicationViewModel.kt */
|
|
|
|
public static abstract class ViewState {
|
|
|
|
|
|
|
|
/* compiled from: DisableGuildCommunicationViewModel.kt */
|
|
|
|
public static final class Invalid extends ViewState {
|
|
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
|
|
|
|
private Invalid() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: DisableGuildCommunicationViewModel.kt */
|
|
|
|
public static final class Valid extends ViewState {
|
|
|
|
private final long guildId;
|
|
|
|
private final TimeDurationDisabledCommunication selectedDurationOption;
|
|
|
|
private final User user;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
2021-12-21 23:37:30 +00:00
|
|
|
public Valid(User user, long j, TimeDurationDisabledCommunication timeDurationDisabledCommunication) {
|
2021-12-17 22:03:14 +00:00
|
|
|
super(null);
|
|
|
|
m.checkNotNullParameter(timeDurationDisabledCommunication, "selectedDurationOption");
|
|
|
|
this.user = user;
|
|
|
|
this.guildId = j;
|
|
|
|
this.selectedDurationOption = timeDurationDisabledCommunication;
|
|
|
|
}
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
public static /* synthetic */ Valid copy$default(Valid valid, User user, long j, TimeDurationDisabledCommunication timeDurationDisabledCommunication, int i, Object obj) {
|
2021-12-17 22:03:14 +00:00
|
|
|
if ((i & 1) != 0) {
|
|
|
|
user = valid.user;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
j = valid.guildId;
|
|
|
|
}
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
timeDurationDisabledCommunication = valid.selectedDurationOption;
|
|
|
|
}
|
2021-12-21 23:37:30 +00:00
|
|
|
return valid.copy(user, j, timeDurationDisabledCommunication);
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final User component1() {
|
|
|
|
return this.user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final long component2() {
|
|
|
|
return this.guildId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final TimeDurationDisabledCommunication component3() {
|
|
|
|
return this.selectedDurationOption;
|
|
|
|
}
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
public final Valid copy(User user, long j, TimeDurationDisabledCommunication timeDurationDisabledCommunication) {
|
2021-12-17 22:03:14 +00:00
|
|
|
m.checkNotNullParameter(timeDurationDisabledCommunication, "selectedDurationOption");
|
2021-12-21 23:37:30 +00:00
|
|
|
return new Valid(user, j, timeDurationDisabledCommunication);
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof Valid)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Valid valid = (Valid) obj;
|
2021-12-21 23:37:30 +00:00
|
|
|
return m.areEqual(this.user, valid.user) && this.guildId == valid.guildId && m.areEqual(this.selectedDurationOption, valid.selectedDurationOption);
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final long getGuildId() {
|
|
|
|
return this.guildId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final TimeDurationDisabledCommunication getSelectedDurationOption() {
|
|
|
|
return this.selectedDurationOption;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final User getUser() {
|
|
|
|
return this.user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
User user = this.user;
|
|
|
|
int i = 0;
|
|
|
|
int a = (b.a(this.guildId) + ((user != null ? user.hashCode() : 0) * 31)) * 31;
|
|
|
|
TimeDurationDisabledCommunication timeDurationDisabledCommunication = this.selectedDurationOption;
|
2021-12-21 23:37:30 +00:00
|
|
|
if (timeDurationDisabledCommunication != null) {
|
|
|
|
i = timeDurationDisabledCommunication.hashCode();
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
2021-12-21 23:37:30 +00:00
|
|
|
return a + i;
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder R = a.R("Valid(user=");
|
|
|
|
R.append(this.user);
|
|
|
|
R.append(", guildId=");
|
|
|
|
R.append(this.guildId);
|
|
|
|
R.append(", selectedDurationOption=");
|
|
|
|
R.append(this.selectedDurationOption);
|
2021-12-21 23:37:30 +00:00
|
|
|
R.append(")");
|
|
|
|
return R.toString();
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private ViewState() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public DisableGuildCommunicationViewModel(long j, long j2, ObservationDeck observationDeck, StoreUser storeUser, StoreGuilds storeGuilds, Observable<StoreState> observable) {
|
|
|
|
super(null, 1, null);
|
|
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
|
|
m.checkNotNullParameter(storeUser, "userStore");
|
|
|
|
m.checkNotNullParameter(storeGuilds, "guildsStore");
|
|
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
|
|
this.userId = j;
|
|
|
|
this.guildId = j2;
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), DisableGuildCommunicationViewModel.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 */ DisableGuildCommunicationViewModel(long j, long j2, ObservationDeck observationDeck, StoreUser storeUser, StoreGuilds storeGuilds, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this(j, j2, r0, r9, r10, (i & 32) != 0 ? Companion.access$observeStores(Companion, j, j2, r0, r9, r10) : observable);
|
|
|
|
ObservationDeck observationDeck2 = (i & 4) != 0 ? ObservationDeckProvider.get() : observationDeck;
|
|
|
|
StoreUser users = (i & 8) != 0 ? StoreStream.Companion.getUsers() : storeUser;
|
|
|
|
StoreGuilds guilds = (i & 16) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds;
|
|
|
|
}
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
public static final /* synthetic */ long access$getGuildId$p(DisableGuildCommunicationViewModel disableGuildCommunicationViewModel) {
|
|
|
|
return disableGuildCommunicationViewModel.guildId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ long access$getUserId$p(DisableGuildCommunicationViewModel disableGuildCommunicationViewModel) {
|
|
|
|
return disableGuildCommunicationViewModel.userId;
|
|
|
|
}
|
|
|
|
|
2021-12-17 22:03:14 +00:00
|
|
|
public static final /* synthetic */ void access$handleStoreState(DisableGuildCommunicationViewModel disableGuildCommunicationViewModel, StoreState storeState) {
|
|
|
|
disableGuildCommunicationViewModel.handleStoreState(storeState);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
|
|
Object obj;
|
|
|
|
TimeDurationDisabledCommunication timeDurationDisabledCommunication;
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (!(viewState instanceof ViewState.Valid)) {
|
|
|
|
viewState = null;
|
|
|
|
}
|
|
|
|
ViewState.Valid valid = (ViewState.Valid) viewState;
|
|
|
|
if (storeState.getGuild() == null) {
|
|
|
|
obj = ViewState.Invalid.INSTANCE;
|
|
|
|
} else {
|
|
|
|
User user = storeState.getUser();
|
|
|
|
long id2 = storeState.getGuild().getId();
|
|
|
|
if (valid == null || (timeDurationDisabledCommunication = valid.getSelectedDurationOption()) == null) {
|
|
|
|
timeDurationDisabledCommunication = TimeDurationDisabledCommunication.SECONDS_60;
|
|
|
|
}
|
2021-12-21 23:37:30 +00:00
|
|
|
obj = new ViewState.Valid(user, id2, timeDurationDisabledCommunication);
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
|
|
|
updateViewState(obj);
|
|
|
|
}
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
public final void onDisableCommunicationConfirm(WeakReference<Context> weakReference, String str, Function0<Unit> function0) {
|
|
|
|
m.checkNotNullParameter(weakReference, "context");
|
2021-12-17 22:03:14 +00:00
|
|
|
m.checkNotNullParameter(function0, "onFinished");
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (viewState instanceof ViewState.Valid) {
|
|
|
|
ViewState.Valid valid = (ViewState.Valid) viewState;
|
2022-01-19 20:19:48 +00:00
|
|
|
Pair<String, Long> futureTimestamp = GuildCommunicationDisabledDateUtils.INSTANCE.getFutureTimestamp(valid.getSelectedDurationOption().getDurationMs());
|
|
|
|
long longValue = futureTimestamp.component2().longValue();
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(RestCallStateKt.logNetworkAction(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().disableGuildCommunication(this.guildId, this.userId, new RestAPIParams.DisableGuildCommunication(futureTimestamp.component1()), str), false, 1, null), new DisableGuildCommunicationViewModel$onDisableCommunicationConfirm$1(this, ((long) valid.getSelectedDurationOption().getDurationMs()) / 1000, longValue, str)), this, null, 2, null), DisableGuildCommunicationViewModel.class, weakReference.get(), (Function1) null, (Function1) null, (Function0) null, (Function0) null, new DisableGuildCommunicationViewModel$onDisableCommunicationConfirm$2(function0), 60, (Object) null);
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void onDurationLengthSelected(TimeDurationDisabledCommunication timeDurationDisabledCommunication) {
|
|
|
|
m.checkNotNullParameter(timeDurationDisabledCommunication, "duration");
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (viewState instanceof ViewState.Valid) {
|
2021-12-21 23:37:30 +00:00
|
|
|
updateViewState(ViewState.Valid.copy$default((ViewState.Valid) viewState, null, 0, timeDurationDisabledCommunication, 3, null));
|
2021-12-17 22:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|