forked from Juby210/discord-jadx
292 lines
14 KiB
Java
292 lines
14 KiB
Java
package com.discord.widgets.user;
|
|
|
|
import android.content.Context;
|
|
import c.d.b.a.a;
|
|
import c0.c0.c;
|
|
import c0.t.k;
|
|
import c0.t.u;
|
|
import c0.z.d.m;
|
|
import c0.z.d.o;
|
|
import com.discord.api.activity.Activity;
|
|
import com.discord.api.activity.ActivityEmoji;
|
|
import com.discord.api.presence.ClientStatus;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.domain.emoji.ModelEmojiUnicode;
|
|
import com.discord.restapi.RestAPIParams;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUserPresence;
|
|
import com.discord.stores.StoreUserSettings;
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
import com.discord.utilities.analytics.Traits;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.widgets.user.profile.UserStatusPresenceCustomView;
|
|
import java.util.Map;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetUserStatusSheetViewModel.kt */
|
|
public final class WidgetUserStatusSheetViewModel extends AppViewModel<ViewState> {
|
|
private static final String[] CUSTOM_EMOJI_PLACEHOLDER_EMOJIS = {"grinning", "grimacing", "grin", "joy", "smiley", "smile", "sweat_smile", "laughing", "innocent", "wink", "blush", "slight_smile", "upside_down", "relaxed", "yum", "relieved", "heart_eyes", "kissing_heart", "kissing", "kissing_smiling_eyes", "kissing_closed_eyes", "stuck_out_tongue_winking_eye", "stuck_out_tongue_closed_eyes", "stuck_out_tongue", "money_mouth", "nerd", "sunglasses", "hugging", "smirk", "no_mouth", "neutral_face", "expressionless", "unamused", "rolling_eyes", "thinking", "flushed", "disappointed", "worried", "angry", "rage", "pensive", "confused", "slight_frown", "frowning2", "persevere", "confounded", "tired_face", "weary", "triumph", "open_mouth", "eggplant"};
|
|
public static final Companion Companion = new Companion(null);
|
|
private boolean hasTrackedOpenPopout;
|
|
private final RestAPI restAPI;
|
|
private final StoreUserPresence storePresences;
|
|
private final StoreUserSettings storeUserSettings;
|
|
|
|
/* compiled from: WidgetUserStatusSheetViewModel.kt */
|
|
/* renamed from: com.discord.widgets.user.WidgetUserStatusSheetViewModel$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
public final /* synthetic */ WidgetUserStatusSheetViewModel this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(WidgetUserStatusSheetViewModel widgetUserStatusSheetViewModel) {
|
|
super(1);
|
|
this.this$0 = widgetUserStatusSheetViewModel;
|
|
}
|
|
|
|
/* 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");
|
|
WidgetUserStatusSheetViewModel.access$handleStoreState(this.this$0, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetUserStatusSheetViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, StoreUserPresence storeUserPresence) {
|
|
return companion.observeStoreState(storeUserPresence);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStoreState(StoreUserPresence storeUserPresence) {
|
|
Observable<R> F = storeUserPresence.observeLocalPresence().F(WidgetUserStatusSheetViewModel$Companion$observeStoreState$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "storePresences\n … )\n }");
|
|
return F;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetUserStatusSheetViewModel.kt */
|
|
public static final class StoreState {
|
|
private final Activity customStatusActivity;
|
|
|
|
public StoreState(Activity activity) {
|
|
this.customStatusActivity = activity;
|
|
}
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, Activity activity, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
activity = storeState.customStatusActivity;
|
|
}
|
|
return storeState.copy(activity);
|
|
}
|
|
|
|
public final Activity component1() {
|
|
return this.customStatusActivity;
|
|
}
|
|
|
|
public final StoreState copy(Activity activity) {
|
|
return new StoreState(activity);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof StoreState) && m.areEqual(this.customStatusActivity, ((StoreState) obj).customStatusActivity);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final Activity getCustomStatusActivity() {
|
|
return this.customStatusActivity;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Activity activity = this.customStatusActivity;
|
|
if (activity != null) {
|
|
return activity.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder O = a.O("StoreState(customStatusActivity=");
|
|
O.append(this.customStatusActivity);
|
|
O.append(")");
|
|
return O.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetUserStatusSheetViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: WidgetUserStatusSheetViewModel.kt */
|
|
public static final class Loaded extends ViewState {
|
|
private final UserStatusPresenceCustomView.ViewState customStatusViewState;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Loaded(UserStatusPresenceCustomView.ViewState viewState) {
|
|
super(null);
|
|
m.checkNotNullParameter(viewState, "customStatusViewState");
|
|
this.customStatusViewState = viewState;
|
|
}
|
|
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, UserStatusPresenceCustomView.ViewState viewState, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
viewState = loaded.customStatusViewState;
|
|
}
|
|
return loaded.copy(viewState);
|
|
}
|
|
|
|
public final UserStatusPresenceCustomView.ViewState component1() {
|
|
return this.customStatusViewState;
|
|
}
|
|
|
|
public final Loaded copy(UserStatusPresenceCustomView.ViewState viewState) {
|
|
m.checkNotNullParameter(viewState, "customStatusViewState");
|
|
return new Loaded(viewState);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof Loaded) && m.areEqual(this.customStatusViewState, ((Loaded) obj).customStatusViewState);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final UserStatusPresenceCustomView.ViewState getCustomStatusViewState() {
|
|
return this.customStatusViewState;
|
|
}
|
|
|
|
public int hashCode() {
|
|
UserStatusPresenceCustomView.ViewState viewState = this.customStatusViewState;
|
|
if (viewState != null) {
|
|
return viewState.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder O = a.O("Loaded(customStatusViewState=");
|
|
O.append(this.customStatusViewState);
|
|
O.append(")");
|
|
return O.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetUserStatusSheetViewModel.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 WidgetUserStatusSheetViewModel() {
|
|
this(null, null, null, null, 15, null);
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetUserStatusSheetViewModel(StoreUserSettings storeUserSettings, StoreUserPresence storeUserPresence, RestAPI restAPI, Observable<StoreState> observable) {
|
|
super(ViewState.Uninitialized.INSTANCE);
|
|
m.checkNotNullParameter(storeUserSettings, "storeUserSettings");
|
|
m.checkNotNullParameter(storeUserPresence, "storePresences");
|
|
m.checkNotNullParameter(restAPI, "restAPI");
|
|
m.checkNotNullParameter(observable, "storeObservable");
|
|
this.storeUserSettings = storeUserSettings;
|
|
this.storePresences = storeUserPresence;
|
|
this.restAPI = restAPI;
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), WidgetUserStatusSheetViewModel.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 */ WidgetUserStatusSheetViewModel(StoreUserSettings storeUserSettings, StoreUserPresence storeUserPresence, RestAPI restAPI, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(storeUserSettings, storeUserPresence, (i & 4) != 0 ? RestAPI.Companion.getApi() : restAPI, (i & 8) != 0 ? Companion.access$observeStoreState(Companion, storeUserPresence) : observable);
|
|
storeUserSettings = (i & 1) != 0 ? StoreStream.Companion.getUserSettings() : storeUserSettings;
|
|
storeUserPresence = (i & 2) != 0 ? StoreStream.Companion.getPresences() : storeUserPresence;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(WidgetUserStatusSheetViewModel widgetUserStatusSheetViewModel, StoreState storeState) {
|
|
widgetUserStatusSheetViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
private final ModelEmojiUnicode getPlaceholderEmoji() {
|
|
Map<String, ModelEmojiUnicode> unicodeEmojisNamesMap = StoreStream.Companion.getEmojis().getUnicodeEmojisNamesMap();
|
|
String[] strArr = CUSTOM_EMOJI_PLACEHOLDER_EMOJIS;
|
|
c.a aVar = c.j;
|
|
ModelEmojiUnicode modelEmojiUnicode = unicodeEmojisNamesMap.get(k.random(strArr, aVar));
|
|
return modelEmojiUnicode != null ? modelEmojiUnicode : (ModelEmojiUnicode) u.random(unicodeEmojisNamesMap.values(), aVar);
|
|
}
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
UserStatusPresenceCustomView.ViewState viewState;
|
|
if (!this.hasTrackedOpenPopout) {
|
|
trackOpen(storeState);
|
|
this.hasTrackedOpenPopout = true;
|
|
}
|
|
Activity customStatusActivity = storeState.getCustomStatusActivity();
|
|
if (customStatusActivity != null) {
|
|
ActivityEmoji f = customStatusActivity.f();
|
|
String str = null;
|
|
String b = f != null ? f.b() : null;
|
|
ActivityEmoji f2 = customStatusActivity.f();
|
|
if (f2 != null) {
|
|
str = f2.c();
|
|
}
|
|
ActivityEmoji f3 = customStatusActivity.f();
|
|
viewState = new UserStatusPresenceCustomView.ViewState.WithStatus(new UserStatusPresenceCustomView.Emoji(b, str, f3 != null ? f3.a() : false), customStatusActivity.l());
|
|
} else {
|
|
viewState = new UserStatusPresenceCustomView.ViewState.WithPlaceholder(getPlaceholderEmoji());
|
|
}
|
|
updateViewState(new ViewState.Loaded(viewState));
|
|
}
|
|
|
|
private final void trackOpen(StoreState storeState) {
|
|
AnalyticsTracker.INSTANCE.openUserStatusSheet(new Traits.Location(null, "Account Panel", "Avatar", null, null, 25, null), storeState.getCustomStatusActivity() != null);
|
|
}
|
|
|
|
public final void clearCustomStatus() {
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.restSubscribeOn$default(this.storeUserSettings.updateCustomStatus(null), false, 1, null), WidgetUserStatusSheetViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, WidgetUserStatusSheetViewModel$clearCustomStatus$1.INSTANCE, 62, (Object) null);
|
|
}
|
|
|
|
public final RestAPI getRestAPI() {
|
|
return this.restAPI;
|
|
}
|
|
|
|
public final StoreUserPresence getStorePresences() {
|
|
return this.storePresences;
|
|
}
|
|
|
|
public final StoreUserSettings getStoreUserSettings() {
|
|
return this.storeUserSettings;
|
|
}
|
|
|
|
public final void setStatus(ClientStatus clientStatus) {
|
|
m.checkNotNullParameter(clientStatus, "status");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.restSubscribeOn$default(this.restAPI.updateUserSettings(RestAPIParams.UserSettings.Companion.createWithStatus(clientStatus)), false, 1, null), WidgetUserStatusSheetViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, WidgetUserStatusSheetViewModel$setStatus$1.INSTANCE, 62, (Object) null);
|
|
}
|
|
}
|