2021-08-09 22:50:52 +00:00
|
|
|
package com.discord.widgets.guilds;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2021-12-17 22:01:24 +00:00
|
|
|
import b.d.b.a.a;
|
2021-08-09 22:50:52 +00:00
|
|
|
import com.discord.R;
|
|
|
|
import com.discord.app.AppViewModel;
|
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
|
|
import com.discord.models.domain.ModelGuildFolder;
|
|
|
|
import com.discord.restapi.RestAPIParams;
|
|
|
|
import com.discord.stores.StoreGuildsSorted;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.stores.StoreUserSettings;
|
|
|
|
import com.discord.utilities.rest.RestAPI;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
2021-11-01 07:19:03 +00:00
|
|
|
import d0.z.d.m;
|
|
|
|
import d0.z.d.o;
|
2021-08-09 22:50:52 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
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: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public final class WidgetGuildFolderSettingsViewModel extends AppViewModel<ViewState> {
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
private final PublishSubject<Event> eventSubject;
|
|
|
|
private final long folderId;
|
|
|
|
private StoreState previousStoreState;
|
|
|
|
private final StoreUserSettings storeUserSettings;
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
/* renamed from: com.discord.widgets.guilds.WidgetGuildFolderSettingsViewModel$1 reason: invalid class name */
|
|
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
|
|
public final /* synthetic */ WidgetGuildFolderSettingsViewModel this$0;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public AnonymousClass1(WidgetGuildFolderSettingsViewModel widgetGuildFolderSettingsViewModel) {
|
|
|
|
super(1);
|
|
|
|
this.this$0 = widgetGuildFolderSettingsViewModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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");
|
|
|
|
WidgetGuildFolderSettingsViewModel.access$handleStoreState(this.this$0, storeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, long j, StoreUserSettings storeUserSettings, StoreGuildsSorted storeGuildsSorted) {
|
|
|
|
return companion.observeStoreState(j, storeUserSettings, storeGuildsSorted);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final Observable<StoreState> observeStoreState(long j, StoreUserSettings storeUserSettings, StoreGuildsSorted storeGuildsSorted) {
|
|
|
|
Observable<StoreState> j2 = Observable.j(storeUserSettings.observeGuildFolders(), storeGuildsSorted.observeEntries(), new WidgetGuildFolderSettingsViewModel$Companion$observeStoreState$1(j));
|
|
|
|
m.checkNotNullExpressionValue(j2, "Observable.combineLatest…Guilds)\n }\n }");
|
|
|
|
return j2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static abstract class Event {
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static final class UpdateFolderSettingsFailure extends Event {
|
|
|
|
private final int failureMessageStringRes;
|
|
|
|
|
|
|
|
public UpdateFolderSettingsFailure(int i) {
|
|
|
|
super(null);
|
|
|
|
this.failureMessageStringRes = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ UpdateFolderSettingsFailure copy$default(UpdateFolderSettingsFailure updateFolderSettingsFailure, int i, int i2, Object obj) {
|
|
|
|
if ((i2 & 1) != 0) {
|
|
|
|
i = updateFolderSettingsFailure.failureMessageStringRes;
|
|
|
|
}
|
|
|
|
return updateFolderSettingsFailure.copy(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int component1() {
|
|
|
|
return this.failureMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final UpdateFolderSettingsFailure copy(int i) {
|
|
|
|
return new UpdateFolderSettingsFailure(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this != obj) {
|
|
|
|
return (obj instanceof UpdateFolderSettingsFailure) && this.failureMessageStringRes == ((UpdateFolderSettingsFailure) obj).failureMessageStringRes;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int getFailureMessageStringRes() {
|
|
|
|
return this.failureMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
return this.failureMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-11-05 21:05:33 +00:00
|
|
|
return a.A(a.R("UpdateFolderSettingsFailure(failureMessageStringRes="), this.failureMessageStringRes, ")");
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static final class UpdateFolderSettingsSuccess extends Event {
|
|
|
|
private final int successMessageStringRes;
|
|
|
|
|
|
|
|
public UpdateFolderSettingsSuccess(int i) {
|
|
|
|
super(null);
|
|
|
|
this.successMessageStringRes = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ UpdateFolderSettingsSuccess copy$default(UpdateFolderSettingsSuccess updateFolderSettingsSuccess, int i, int i2, Object obj) {
|
|
|
|
if ((i2 & 1) != 0) {
|
|
|
|
i = updateFolderSettingsSuccess.successMessageStringRes;
|
|
|
|
}
|
|
|
|
return updateFolderSettingsSuccess.copy(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int component1() {
|
|
|
|
return this.successMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final UpdateFolderSettingsSuccess copy(int i) {
|
|
|
|
return new UpdateFolderSettingsSuccess(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this != obj) {
|
|
|
|
return (obj instanceof UpdateFolderSettingsSuccess) && this.successMessageStringRes == ((UpdateFolderSettingsSuccess) obj).successMessageStringRes;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int getSuccessMessageStringRes() {
|
|
|
|
return this.successMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
return this.successMessageStringRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-11-05 21:05:33 +00:00
|
|
|
return a.A(a.R("UpdateFolderSettingsSuccess(successMessageStringRes="), this.successMessageStringRes, ")");
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Event() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static final class FormState {
|
|
|
|
private final Integer color;
|
|
|
|
private final String name;
|
|
|
|
|
|
|
|
public FormState(String str, Integer num) {
|
|
|
|
this.name = str;
|
|
|
|
this.color = num;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ FormState copy$default(FormState formState, String str, Integer num, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
str = formState.name;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
num = formState.color;
|
|
|
|
}
|
|
|
|
return formState.copy(str, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String component1() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Integer component2() {
|
|
|
|
return this.color;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final FormState copy(String str, Integer num) {
|
|
|
|
return new FormState(str, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof FormState)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
FormState formState = (FormState) obj;
|
|
|
|
return m.areEqual(this.name, formState.name) && m.areEqual(this.color, formState.color);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Integer getColor() {
|
|
|
|
return this.color;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String getName() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
String str = this.name;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
|
|
Integer num = this.color;
|
|
|
|
if (num != null) {
|
|
|
|
i = num.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-11-05 21:05:33 +00:00
|
|
|
StringBuilder R = a.R("FormState(name=");
|
|
|
|
R.append(this.name);
|
|
|
|
R.append(", color=");
|
|
|
|
return a.E(R, this.color, ")");
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static abstract class StoreState {
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static final class Invalid extends StoreState {
|
|
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
|
|
|
|
private Invalid() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static final class Valid extends StoreState {
|
|
|
|
private final ModelGuildFolder folder;
|
|
|
|
private final List<StoreGuildsSorted.Entry> sortedGuilds;
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: java.util.List<? extends com.discord.stores.StoreGuildsSorted$Entry> */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public Valid(ModelGuildFolder modelGuildFolder, List<? extends StoreGuildsSorted.Entry> list) {
|
|
|
|
super(null);
|
|
|
|
m.checkNotNullParameter(modelGuildFolder, "folder");
|
|
|
|
m.checkNotNullParameter(list, "sortedGuilds");
|
|
|
|
this.folder = modelGuildFolder;
|
|
|
|
this.sortedGuilds = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guilds.WidgetGuildFolderSettingsViewModel$StoreState$Valid */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public static /* synthetic */ Valid copy$default(Valid valid, ModelGuildFolder modelGuildFolder, List list, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
modelGuildFolder = valid.folder;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
list = valid.sortedGuilds;
|
|
|
|
}
|
|
|
|
return valid.copy(modelGuildFolder, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelGuildFolder component1() {
|
|
|
|
return this.folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<StoreGuildsSorted.Entry> component2() {
|
|
|
|
return this.sortedGuilds;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Valid copy(ModelGuildFolder modelGuildFolder, List<? extends StoreGuildsSorted.Entry> list) {
|
|
|
|
m.checkNotNullParameter(modelGuildFolder, "folder");
|
|
|
|
m.checkNotNullParameter(list, "sortedGuilds");
|
|
|
|
return new Valid(modelGuildFolder, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof Valid)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Valid valid = (Valid) obj;
|
|
|
|
return m.areEqual(this.folder, valid.folder) && m.areEqual(this.sortedGuilds, valid.sortedGuilds);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelGuildFolder getFolder() {
|
|
|
|
return this.folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<StoreGuildsSorted.Entry> getSortedGuilds() {
|
|
|
|
return this.sortedGuilds;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
ModelGuildFolder modelGuildFolder = this.folder;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (modelGuildFolder != null ? modelGuildFolder.hashCode() : 0) * 31;
|
|
|
|
List<StoreGuildsSorted.Entry> list = this.sortedGuilds;
|
|
|
|
if (list != null) {
|
|
|
|
i = list.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-11-05 21:05:33 +00:00
|
|
|
StringBuilder R = a.R("Valid(folder=");
|
|
|
|
R.append(this.folder);
|
|
|
|
R.append(", sortedGuilds=");
|
2022-01-17 16:29:36 +00:00
|
|
|
return a.K(R, this.sortedGuilds, ")");
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private StoreState() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ StoreState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static abstract class ViewState {
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.kt */
|
|
|
|
public static final class Loaded extends ViewState {
|
|
|
|
private final FormState formState;
|
|
|
|
private final boolean showSave;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public Loaded(FormState formState, boolean z2) {
|
|
|
|
super(null);
|
|
|
|
m.checkNotNullParameter(formState, "formState");
|
|
|
|
this.formState = formState;
|
|
|
|
this.showSave = z2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, FormState formState, boolean z2, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
formState = loaded.formState;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
z2 = loaded.showSave;
|
|
|
|
}
|
|
|
|
return loaded.copy(formState, z2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final FormState component1() {
|
|
|
|
return this.formState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component2() {
|
|
|
|
return this.showSave;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Loaded copy(FormState formState, boolean z2) {
|
|
|
|
m.checkNotNullParameter(formState, "formState");
|
|
|
|
return new Loaded(formState, z2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof Loaded)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Loaded loaded = (Loaded) obj;
|
|
|
|
return m.areEqual(this.formState, loaded.formState) && this.showSave == loaded.showSave;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final FormState getFormState() {
|
|
|
|
return this.formState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean getShowSave() {
|
|
|
|
return this.showSave;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
FormState formState = this.formState;
|
|
|
|
int hashCode = (formState != null ? formState.hashCode() : 0) * 31;
|
|
|
|
boolean z2 = this.showSave;
|
|
|
|
if (z2) {
|
|
|
|
z2 = true;
|
|
|
|
}
|
|
|
|
int i = z2 ? 1 : 0;
|
|
|
|
int i2 = z2 ? 1 : 0;
|
|
|
|
int i3 = z2 ? 1 : 0;
|
|
|
|
return hashCode + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-11-05 21:05:33 +00:00
|
|
|
StringBuilder R = a.R("Loaded(formState=");
|
|
|
|
R.append(this.formState);
|
|
|
|
R.append(", showSave=");
|
2022-01-17 16:29:36 +00:00
|
|
|
return a.M(R, this.showSave, ")");
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetGuildFolderSettingsViewModel.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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public WidgetGuildFolderSettingsViewModel(long j, StoreUserSettings storeUserSettings, StoreGuildsSorted storeGuildsSorted) {
|
|
|
|
super(ViewState.Uninitialized.INSTANCE);
|
|
|
|
m.checkNotNullParameter(storeUserSettings, "storeUserSettings");
|
|
|
|
m.checkNotNullParameter(storeGuildsSorted, "storeGuildsSorted");
|
|
|
|
this.folderId = j;
|
|
|
|
this.storeUserSettings = storeUserSettings;
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(Companion.access$observeStoreState(Companion, j, storeUserSettings, storeGuildsSorted)), this, null, 2, null), WidgetGuildFolderSettingsViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
2021-10-22 07:30:30 +00:00
|
|
|
this.eventSubject = PublishSubject.k0();
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
|
|
public /* synthetic */ WidgetGuildFolderSettingsViewModel(long j, StoreUserSettings storeUserSettings, StoreGuildsSorted storeGuildsSorted, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this(j, (i & 2) != 0 ? StoreStream.Companion.getUserSettings() : storeUserSettings, (i & 4) != 0 ? StoreStream.Companion.getGuildsSorted() : storeGuildsSorted);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$emitUpdateFailureEvent(WidgetGuildFolderSettingsViewModel widgetGuildFolderSettingsViewModel) {
|
|
|
|
widgetGuildFolderSettingsViewModel.emitUpdateFailureEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$emitUpdateSuccessEvent(WidgetGuildFolderSettingsViewModel widgetGuildFolderSettingsViewModel) {
|
|
|
|
widgetGuildFolderSettingsViewModel.emitUpdateSuccessEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(WidgetGuildFolderSettingsViewModel widgetGuildFolderSettingsViewModel, StoreState storeState) {
|
|
|
|
widgetGuildFolderSettingsViewModel.handleStoreState(storeState);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void emitUpdateFailureEvent() {
|
|
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
2021-12-17 22:01:24 +00:00
|
|
|
publishSubject.k.onNext(new Event.UpdateFolderSettingsFailure(R.string.default_failure_to_perform_action_message));
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final void emitUpdateSuccessEvent() {
|
|
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
2021-12-17 22:01:24 +00:00
|
|
|
publishSubject.k.onNext(new Event.UpdateFolderSettingsSuccess(R.string.guild_folder_updated_success));
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
|
|
this.previousStoreState = storeState;
|
|
|
|
if (storeState instanceof StoreState.Valid) {
|
|
|
|
StoreState.Valid valid = (StoreState.Valid) storeState;
|
|
|
|
FormState formState = new FormState(valid.getFolder().getName(), valid.getFolder().getColor());
|
|
|
|
updateViewState(new ViewState.Loaded(formState, shouldShowSave(valid, formState)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final boolean shouldShowSave(StoreState.Valid valid, FormState formState) {
|
|
|
|
return (m.areEqual(valid.getFolder().getColor(), formState.getColor()) ^ true) || (m.areEqual(valid.getFolder().getName(), formState.getName()) ^ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
StoreState storeState = this.previousStoreState;
|
|
|
|
updateViewState(loaded.copy(formState, storeState instanceof StoreState.Valid ? shouldShowSave((StoreState.Valid) storeState, formState) : false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final long getFolderId() {
|
|
|
|
return this.folderId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final StoreState getPreviousStoreState() {
|
|
|
|
return this.previousStoreState;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 saveFolder() {
|
|
|
|
ModelGuildFolder modelGuildFolder;
|
|
|
|
StoreState storeState = this.previousStoreState;
|
|
|
|
if (!(storeState instanceof StoreState.Valid)) {
|
|
|
|
storeState = null;
|
|
|
|
}
|
|
|
|
StoreState.Valid valid = (StoreState.Valid) storeState;
|
|
|
|
if (valid != null) {
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (!(viewState instanceof ViewState.Loaded)) {
|
|
|
|
viewState = null;
|
|
|
|
}
|
|
|
|
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
|
|
|
|
if (loaded != null) {
|
|
|
|
FormState formState = loaded.getFormState();
|
|
|
|
List<StoreGuildsSorted.Entry> sortedGuilds = valid.getSortedGuilds();
|
2021-11-01 07:19:03 +00:00
|
|
|
ArrayList arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(sortedGuilds, 10));
|
2021-08-09 22:50:52 +00:00
|
|
|
for (StoreGuildsSorted.Entry entry : sortedGuilds) {
|
|
|
|
if (entry instanceof StoreGuildsSorted.Entry.SingletonGuild) {
|
|
|
|
modelGuildFolder = entry.asModelGuildFolder();
|
|
|
|
} else if (entry instanceof StoreGuildsSorted.Entry.Folder) {
|
|
|
|
StoreGuildsSorted.Entry.Folder folder = (StoreGuildsSorted.Entry.Folder) entry;
|
|
|
|
modelGuildFolder = folder.getId() == this.folderId ? StoreGuildsSorted.Entry.Folder.copy$default(folder, 0, null, formState.getColor(), formState.getName(), 3, null).asModelGuildFolder() : entry.asModelGuildFolder();
|
|
|
|
} else {
|
|
|
|
throw new NoWhenBranchMatchedException();
|
|
|
|
}
|
|
|
|
arrayList.add(modelGuildFolder);
|
|
|
|
}
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().updateUserSettings(RestAPIParams.UserSettings.Companion.createWithGuildFolders(arrayList)), false, 1, null), this, null, 2, null), WidgetGuildFolderSettingsViewModel.class, (Context) null, (Function1) null, new WidgetGuildFolderSettingsViewModel$saveFolder$2(this), (Function0) null, (Function0) null, new WidgetGuildFolderSettingsViewModel$saveFolder$1(this), 54, (Object) null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setColor(Integer num) {
|
|
|
|
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, num, 1, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setName(String str) {
|
|
|
|
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
|
|
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(), str, null, 2, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setPreviousStoreState(StoreState storeState) {
|
|
|
|
this.previousStoreState = storeState;
|
|
|
|
}
|
|
|
|
}
|