2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.widgets.user;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.discord.app.AppViewModel;
|
|
|
|
import com.discord.models.domain.ModelCustomStatusSetting;
|
|
|
|
import com.discord.models.domain.emoji.Emoji;
|
|
|
|
import com.discord.models.domain.emoji.EmojiSet;
|
|
|
|
import com.discord.models.domain.emoji.ModelEmojiCustom;
|
|
|
|
import com.discord.models.domain.emoji.ModelEmojiUnicode;
|
|
|
|
import com.discord.stores.StoreEmoji;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.stores.StoreUserSettings;
|
|
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
|
|
import com.discord.utilities.analytics.Traits;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import com.discord.utilities.time.Clock;
|
|
|
|
import com.discord.utilities.time.ClockFactory;
|
|
|
|
import com.discord.utilities.time.TimeUtils;
|
|
|
|
import d0.g0.w;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import d0.z.d.o;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Objects;
|
|
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
|
|
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: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public final class WidgetUserSetCustomStatusViewModel extends AppViewModel<ViewState> {
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
private static final FormState.Expiration DEFAULT_EXPIRATION = FormState.Expiration.TOMORROW;
|
|
|
|
private final Clock clock;
|
|
|
|
private final PublishSubject<Event> eventSubject;
|
|
|
|
private final StoreUserSettings storeUserSettings;
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
/* renamed from: com.discord.widgets.user.WidgetUserSetCustomStatusViewModel$1 reason: invalid class name */
|
|
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
|
|
public final /* synthetic */ WidgetUserSetCustomStatusViewModel this$0;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public AnonymousClass1(WidgetUserSetCustomStatusViewModel widgetUserSetCustomStatusViewModel) {
|
|
|
|
super(1);
|
|
|
|
this.this$0 = widgetUserSetCustomStatusViewModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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, "storeState");
|
|
|
|
WidgetUserSetCustomStatusViewModel.access$handleStoreState(this.this$0, storeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, StoreUserSettings storeUserSettings, StoreEmoji storeEmoji) {
|
|
|
|
return companion.observeStoreState(storeUserSettings, storeEmoji);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final Observable<StoreState> observeStoreState(StoreUserSettings storeUserSettings, StoreEmoji storeEmoji) {
|
2021-07-03 23:36:06 +00:00
|
|
|
Observable<StoreState> Z = Observable.j(storeUserSettings.observeCustomStatus(), storeEmoji.getEmojiSet(StoreEmoji.EmojiContext.Global.INSTANCE, false, false), WidgetUserSetCustomStatusViewModel$Companion$observeStoreState$1.INSTANCE).Z(1);
|
|
|
|
m.checkNotNullExpressionValue(Z, "Observable.combineLatest… )\n }.take(1)");
|
|
|
|
return Z;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final FormState.Expiration getDEFAULT_EXPIRATION() {
|
|
|
|
return WidgetUserSetCustomStatusViewModel.access$getDEFAULT_EXPIRATION$cp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static abstract class Event {
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static final class SetStatusFailure extends Event {
|
|
|
|
private final int failureMessageStringRes;
|
|
|
|
|
|
|
|
public SetStatusFailure(int i) {
|
|
|
|
super(null);
|
|
|
|
this.failureMessageStringRes = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ SetStatusFailure copy$default(SetStatusFailure setStatusFailure, int i, int i2, Object obj) {
|
|
|
|
if ((i2 & 1) != 0) {
|
|
|
|
i = setStatusFailure.failureMessageStringRes;
|
|
|
|
}
|
|
|
|
return setStatusFailure.copy(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int component1() {
|
|
|
|
return this.failureMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final SetStatusFailure copy(int i) {
|
|
|
|
return new SetStatusFailure(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this != obj) {
|
|
|
|
return (obj instanceof SetStatusFailure) && this.failureMessageStringRes == ((SetStatusFailure) obj).failureMessageStringRes;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int getFailureMessageStringRes() {
|
|
|
|
return this.failureMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
return this.failureMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-07-13 20:23:20 +00:00
|
|
|
return a.y(a.L("SetStatusFailure(failureMessageStringRes="), this.failureMessageStringRes, ")");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static final class SetStatusSuccess extends Event {
|
|
|
|
private final int successMessageStringRes;
|
|
|
|
|
|
|
|
public SetStatusSuccess(int i) {
|
|
|
|
super(null);
|
|
|
|
this.successMessageStringRes = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ SetStatusSuccess copy$default(SetStatusSuccess setStatusSuccess, int i, int i2, Object obj) {
|
|
|
|
if ((i2 & 1) != 0) {
|
|
|
|
i = setStatusSuccess.successMessageStringRes;
|
|
|
|
}
|
|
|
|
return setStatusSuccess.copy(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int component1() {
|
|
|
|
return this.successMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final SetStatusSuccess copy(int i) {
|
|
|
|
return new SetStatusSuccess(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this != obj) {
|
|
|
|
return (obj instanceof SetStatusSuccess) && this.successMessageStringRes == ((SetStatusSuccess) obj).successMessageStringRes;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int getSuccessMessageStringRes() {
|
|
|
|
return this.successMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
return this.successMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-07-13 20:23:20 +00:00
|
|
|
return a.y(a.L("SetStatusSuccess(successMessageStringRes="), this.successMessageStringRes, ")");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Event() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static final class FormState {
|
|
|
|
private final Emoji emoji;
|
|
|
|
private final Expiration expiration;
|
|
|
|
private final String text;
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public enum Expiration {
|
|
|
|
NEVER,
|
|
|
|
IN_30_MINUTES,
|
|
|
|
IN_1_HOUR,
|
|
|
|
IN_4_HOURS,
|
|
|
|
TOMORROW
|
|
|
|
}
|
|
|
|
|
|
|
|
public FormState(Emoji emoji, String str, Expiration expiration) {
|
|
|
|
m.checkNotNullParameter(str, "text");
|
|
|
|
m.checkNotNullParameter(expiration, "expiration");
|
|
|
|
this.emoji = emoji;
|
|
|
|
this.text = str;
|
|
|
|
this.expiration = expiration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ FormState copy$default(FormState formState, Emoji emoji, String str, Expiration expiration, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
emoji = formState.emoji;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
str = formState.text;
|
|
|
|
}
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
expiration = formState.expiration;
|
|
|
|
}
|
|
|
|
return formState.copy(emoji, str, expiration);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Emoji component1() {
|
|
|
|
return this.emoji;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String component2() {
|
|
|
|
return this.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Expiration component3() {
|
|
|
|
return this.expiration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final FormState copy(Emoji emoji, String str, Expiration expiration) {
|
|
|
|
m.checkNotNullParameter(str, "text");
|
|
|
|
m.checkNotNullParameter(expiration, "expiration");
|
|
|
|
return new FormState(emoji, str, expiration);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof FormState)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
FormState formState = (FormState) obj;
|
|
|
|
return m.areEqual(this.emoji, formState.emoji) && m.areEqual(this.text, formState.text) && m.areEqual(this.expiration, formState.expiration);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Emoji getEmoji() {
|
|
|
|
return this.emoji;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Expiration getExpiration() {
|
|
|
|
return this.expiration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String getText() {
|
|
|
|
return this.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
Emoji emoji = this.emoji;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (emoji != null ? emoji.hashCode() : 0) * 31;
|
|
|
|
String str = this.text;
|
|
|
|
int hashCode2 = (hashCode + (str != null ? str.hashCode() : 0)) * 31;
|
|
|
|
Expiration expiration = this.expiration;
|
|
|
|
if (expiration != null) {
|
|
|
|
i = expiration.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode2 + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder L = a.L("FormState(emoji=");
|
|
|
|
L.append(this.emoji);
|
|
|
|
L.append(", text=");
|
|
|
|
L.append(this.text);
|
|
|
|
L.append(", expiration=");
|
|
|
|
L.append(this.expiration);
|
|
|
|
L.append(")");
|
|
|
|
return L.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static final class StoreState {
|
|
|
|
private final ModelCustomStatusSetting customStatusSetting;
|
|
|
|
private final EmojiSet emojiSet;
|
|
|
|
|
|
|
|
public StoreState(ModelCustomStatusSetting modelCustomStatusSetting, EmojiSet emojiSet) {
|
|
|
|
m.checkNotNullParameter(modelCustomStatusSetting, "customStatusSetting");
|
|
|
|
m.checkNotNullParameter(emojiSet, "emojiSet");
|
|
|
|
this.customStatusSetting = modelCustomStatusSetting;
|
|
|
|
this.emojiSet = emojiSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, ModelCustomStatusSetting modelCustomStatusSetting, EmojiSet emojiSet, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
modelCustomStatusSetting = storeState.customStatusSetting;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
emojiSet = storeState.emojiSet;
|
|
|
|
}
|
|
|
|
return storeState.copy(modelCustomStatusSetting, emojiSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelCustomStatusSetting component1() {
|
|
|
|
return this.customStatusSetting;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final EmojiSet component2() {
|
|
|
|
return this.emojiSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final StoreState copy(ModelCustomStatusSetting modelCustomStatusSetting, EmojiSet emojiSet) {
|
|
|
|
m.checkNotNullParameter(modelCustomStatusSetting, "customStatusSetting");
|
|
|
|
m.checkNotNullParameter(emojiSet, "emojiSet");
|
|
|
|
return new StoreState(modelCustomStatusSetting, emojiSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof StoreState)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
StoreState storeState = (StoreState) obj;
|
|
|
|
return m.areEqual(this.customStatusSetting, storeState.customStatusSetting) && m.areEqual(this.emojiSet, storeState.emojiSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelCustomStatusSetting getCustomStatusSetting() {
|
|
|
|
return this.customStatusSetting;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final EmojiSet getEmojiSet() {
|
|
|
|
return this.emojiSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
ModelCustomStatusSetting modelCustomStatusSetting = this.customStatusSetting;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (modelCustomStatusSetting != null ? modelCustomStatusSetting.hashCode() : 0) * 31;
|
|
|
|
EmojiSet emojiSet = this.emojiSet;
|
|
|
|
if (emojiSet != null) {
|
|
|
|
i = emojiSet.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder L = a.L("StoreState(customStatusSetting=");
|
|
|
|
L.append(this.customStatusSetting);
|
|
|
|
L.append(", emojiSet=");
|
|
|
|
L.append(this.emojiSet);
|
|
|
|
L.append(")");
|
|
|
|
return L.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static abstract class ViewState {
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static final class Loaded extends ViewState {
|
|
|
|
private final FormState formState;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public Loaded(FormState formState) {
|
|
|
|
super(null);
|
|
|
|
m.checkNotNullParameter(formState, "formState");
|
|
|
|
this.formState = formState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, FormState formState, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
formState = loaded.formState;
|
|
|
|
}
|
|
|
|
return loaded.copy(formState);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final FormState component1() {
|
|
|
|
return this.formState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Loaded copy(FormState formState) {
|
|
|
|
m.checkNotNullParameter(formState, "formState");
|
|
|
|
return new Loaded(formState);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this != obj) {
|
|
|
|
return (obj instanceof Loaded) && m.areEqual(this.formState, ((Loaded) obj).formState);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final FormState getFormState() {
|
|
|
|
return this.formState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean getShowStatusClear() {
|
|
|
|
if (this.formState.getEmoji() == null) {
|
|
|
|
if (!(this.formState.getText().length() > 0)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
FormState formState = this.formState;
|
|
|
|
if (formState != null) {
|
|
|
|
return formState.hashCode();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder L = a.L("Loaded(formState=");
|
|
|
|
L.append(this.formState);
|
|
|
|
L.append(")");
|
|
|
|
return L.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetUserSetCustomStatusViewModel.kt */
|
|
|
|
public static final class Uninitialized extends ViewState {
|
|
|
|
public static final Uninitialized INSTANCE = new Uninitialized();
|
|
|
|
|
|
|
|
private Uninitialized() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private ViewState() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
|
|
|
|
static {
|
|
|
|
FormState.Expiration.values();
|
|
|
|
int[] iArr = new int[5];
|
|
|
|
$EnumSwitchMapping$0 = iArr;
|
|
|
|
iArr[FormState.Expiration.NEVER.ordinal()] = 1;
|
|
|
|
iArr[FormState.Expiration.IN_30_MINUTES.ordinal()] = 2;
|
|
|
|
iArr[FormState.Expiration.IN_1_HOUR.ordinal()] = 3;
|
|
|
|
iArr[FormState.Expiration.IN_4_HOURS.ordinal()] = 4;
|
|
|
|
iArr[FormState.Expiration.TOMORROW.ordinal()] = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WidgetUserSetCustomStatusViewModel() {
|
|
|
|
this(null, null, null, 7, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public WidgetUserSetCustomStatusViewModel(StoreUserSettings storeUserSettings, Clock clock, Observable<StoreState> observable) {
|
|
|
|
super(ViewState.Uninitialized.INSTANCE);
|
|
|
|
m.checkNotNullParameter(storeUserSettings, "storeUserSettings");
|
|
|
|
m.checkNotNullParameter(clock, "clock");
|
|
|
|
m.checkNotNullParameter(observable, "storeObservable");
|
|
|
|
this.storeUserSettings = storeUserSettings;
|
|
|
|
this.clock = clock;
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), WidgetUserSetCustomStatusViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
2021-07-03 23:36:06 +00:00
|
|
|
this.eventSubject = PublishSubject.k0();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
|
|
public /* synthetic */ WidgetUserSetCustomStatusViewModel(StoreUserSettings storeUserSettings, Clock clock, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this(storeUserSettings, clock, observable);
|
|
|
|
storeUserSettings = (i & 1) != 0 ? StoreStream.Companion.getUserSettings() : storeUserSettings;
|
|
|
|
clock = (i & 2) != 0 ? ClockFactory.get() : clock;
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
Companion companion = Companion;
|
|
|
|
StoreStream.Companion companion2 = StoreStream.Companion;
|
|
|
|
observable = Companion.access$observeStoreState(companion, companion2.getUserSettings(), companion2.getEmojis());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$emitSetStatusFailureEvent(WidgetUserSetCustomStatusViewModel widgetUserSetCustomStatusViewModel) {
|
|
|
|
widgetUserSetCustomStatusViewModel.emitSetStatusFailureEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$emitSetStatusSuccessEvent(WidgetUserSetCustomStatusViewModel widgetUserSetCustomStatusViewModel) {
|
|
|
|
widgetUserSetCustomStatusViewModel.emitSetStatusSuccessEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ FormState.Expiration access$getDEFAULT_EXPIRATION$cp() {
|
|
|
|
return DEFAULT_EXPIRATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(WidgetUserSetCustomStatusViewModel widgetUserSetCustomStatusViewModel, StoreState storeState) {
|
|
|
|
widgetUserSetCustomStatusViewModel.handleStoreState(storeState);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void emitSetStatusFailureEvent() {
|
|
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
2021-07-13 20:23:20 +00:00
|
|
|
publishSubject.j.onNext(new Event.SetStatusFailure(2131888049));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final void emitSetStatusSuccessEvent() {
|
|
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
2021-07-13 20:23:20 +00:00
|
|
|
publishSubject.j.onNext(new Event.SetStatusSuccess(2131888004));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final Emoji getEmojiFromSetting(ModelCustomStatusSetting modelCustomStatusSetting, EmojiSet emojiSet) {
|
|
|
|
String str;
|
|
|
|
if (modelCustomStatusSetting == ModelCustomStatusSetting.Companion.getCLEAR()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
Long emojiId = modelCustomStatusSetting.getEmojiId();
|
|
|
|
if (emojiId == null || (str = String.valueOf(emojiId.longValue())) == null) {
|
|
|
|
str = modelCustomStatusSetting.getEmojiName();
|
|
|
|
}
|
|
|
|
return emojiSet.emojiIndex.get(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final String getExpirationUTCDateString(FormState.Expiration expiration) {
|
|
|
|
Long l;
|
|
|
|
long currentTimeMillis = this.clock.currentTimeMillis();
|
|
|
|
int ordinal = expiration.ordinal();
|
|
|
|
if (ordinal == 0) {
|
|
|
|
l = null;
|
|
|
|
} else if (ordinal == 1) {
|
|
|
|
l = Long.valueOf(currentTimeMillis + 1800000);
|
|
|
|
} else if (ordinal == 2) {
|
|
|
|
l = Long.valueOf(currentTimeMillis + 3600000);
|
|
|
|
} else if (ordinal == 3) {
|
|
|
|
l = Long.valueOf(currentTimeMillis + 14400000);
|
|
|
|
} else if (ordinal == 4) {
|
|
|
|
Calendar calendar = TimeUtils.toCalendar(currentTimeMillis);
|
|
|
|
calendar.add(5, 1);
|
|
|
|
calendar.set(11, 0);
|
|
|
|
calendar.set(12, 0);
|
|
|
|
calendar.set(13, 0);
|
|
|
|
calendar.set(14, 0);
|
|
|
|
l = Long.valueOf(calendar.getTimeInMillis());
|
|
|
|
} else {
|
|
|
|
throw new NoWhenBranchMatchedException();
|
|
|
|
}
|
|
|
|
return TimeUtils.toUTCDateTime$default(l, null, 2, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final String getStatusTextFromSetting(ModelCustomStatusSetting modelCustomStatusSetting) {
|
|
|
|
if (modelCustomStatusSetting != ModelCustomStatusSetting.Companion.getCLEAR()) {
|
|
|
|
return modelCustomStatusSetting.getText();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
|
|
if (!(getViewState() instanceof ViewState.Loaded)) {
|
|
|
|
Emoji emojiFromSetting = getEmojiFromSetting(storeState.getCustomStatusSetting(), storeState.getEmojiSet());
|
|
|
|
String statusTextFromSetting = getStatusTextFromSetting(storeState.getCustomStatusSetting());
|
|
|
|
if (statusTextFromSetting == null) {
|
|
|
|
statusTextFromSetting = "";
|
|
|
|
}
|
|
|
|
updateViewState(new ViewState.Loaded(new FormState(emojiFromSetting, statusTextFromSetting, DEFAULT_EXPIRATION)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void updateFormState(FormState formState) {
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (!(viewState instanceof ViewState.Loaded)) {
|
|
|
|
viewState = null;
|
|
|
|
}
|
|
|
|
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
|
|
|
|
if (loaded != null) {
|
|
|
|
updateViewState(loaded.copy(formState));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void clearStatusTextAndEmoji() {
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (!(viewState instanceof ViewState.Loaded)) {
|
|
|
|
viewState = null;
|
|
|
|
}
|
|
|
|
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
|
|
|
|
if (loaded != null) {
|
|
|
|
updateFormState(FormState.copy$default(loaded.getFormState(), null, "", null, 4, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Clock getClock() {
|
|
|
|
return this.clock;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final StoreUserSettings getStoreUserSettings() {
|
|
|
|
return this.storeUserSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Observable<Event> observeEvents() {
|
|
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
|
|
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
|
|
|
|
return publishSubject;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void saveStatus() {
|
|
|
|
ModelCustomStatusSetting modelCustomStatusSetting;
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (!(viewState instanceof ViewState.Loaded)) {
|
|
|
|
viewState = null;
|
|
|
|
}
|
|
|
|
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
|
|
|
|
if (loaded != null) {
|
|
|
|
FormState formState = loaded.getFormState();
|
|
|
|
String text = formState.getText();
|
|
|
|
Objects.requireNonNull(text, "null cannot be cast to non-null type kotlin.CharSequence");
|
|
|
|
String obj = w.trim(text).toString();
|
|
|
|
if (!(obj.length() > 0)) {
|
|
|
|
obj = null;
|
|
|
|
}
|
|
|
|
FormState formState2 = obj != null || formState.getEmoji() != null ? formState : null;
|
|
|
|
if (formState2 != null) {
|
|
|
|
Emoji emoji = formState2.getEmoji();
|
|
|
|
if (!(emoji instanceof ModelEmojiCustom)) {
|
|
|
|
emoji = null;
|
|
|
|
}
|
|
|
|
ModelEmojiCustom modelEmojiCustom = (ModelEmojiCustom) emoji;
|
|
|
|
Long valueOf = modelEmojiCustom != null ? Long.valueOf(modelEmojiCustom.getId()) : null;
|
|
|
|
Emoji emoji2 = formState2.getEmoji();
|
|
|
|
if (!(emoji2 instanceof ModelEmojiUnicode)) {
|
|
|
|
emoji2 = null;
|
|
|
|
}
|
|
|
|
ModelEmojiUnicode modelEmojiUnicode = (ModelEmojiUnicode) emoji2;
|
|
|
|
modelCustomStatusSetting = new ModelCustomStatusSetting(obj, valueOf, modelEmojiUnicode != null ? modelEmojiUnicode.getSurrogates() : null, getExpirationUTCDateString(formState2.getExpiration()));
|
|
|
|
} else {
|
|
|
|
modelCustomStatusSetting = null;
|
|
|
|
}
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(this.storeUserSettings.updateCustomStatus(modelCustomStatusSetting), false, 1, null), this, null, 2, null), WidgetUserSetCustomStatusViewModel.class, (Context) null, (Function1) null, new WidgetUserSetCustomStatusViewModel$saveStatus$2(this), (Function0) null, (Function0) null, new WidgetUserSetCustomStatusViewModel$saveStatus$1(this), 54, (Object) null);
|
|
|
|
if (modelCustomStatusSetting != null) {
|
|
|
|
AnalyticsTracker.INSTANCE.customStatusUpdated(formState, new Traits.Location(null, "Account Panel", "Avatar", null, null, 25, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setExpiration(FormState.Expiration expiration) {
|
|
|
|
m.checkNotNullParameter(expiration, "expiration");
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (!(viewState instanceof ViewState.Loaded)) {
|
|
|
|
viewState = null;
|
|
|
|
}
|
|
|
|
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
|
|
|
|
if (loaded != null) {
|
|
|
|
updateFormState(FormState.copy$default(loaded.getFormState(), null, null, expiration, 3, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setStatusEmoji(Emoji emoji) {
|
|
|
|
m.checkNotNullParameter(emoji, "emoji");
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (!(viewState instanceof ViewState.Loaded)) {
|
|
|
|
viewState = null;
|
|
|
|
}
|
|
|
|
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
|
|
|
|
if (loaded != null) {
|
|
|
|
updateFormState(FormState.copy$default(loaded.getFormState(), emoji, null, null, 6, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setStatusText(String str) {
|
|
|
|
m.checkNotNullParameter(str, "text");
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (!(viewState instanceof ViewState.Loaded)) {
|
|
|
|
viewState = null;
|
|
|
|
}
|
|
|
|
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
|
|
|
|
if (loaded != null) {
|
|
|
|
updateFormState(FormState.copy$default(loaded.getFormState(), null, str, null, 5, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|