2021-08-03 07:33:18 +00:00
|
|
|
package com.discord.widgets.guilds.invite;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import androidx.annotation.MainThread;
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.discord.api.channel.Channel;
|
|
|
|
import com.discord.app.AppViewModel;
|
|
|
|
import com.discord.models.domain.ModelInvite;
|
|
|
|
import com.discord.stores.StoreInviteSettings;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import d0.t.u;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import d0.z.d.o;
|
|
|
|
import java.util.List;
|
|
|
|
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;
|
|
|
|
import rx.subjects.PublishSubject;
|
|
|
|
/* compiled from: GuildInviteSettingsViewModel.kt */
|
|
|
|
public final class GuildInviteSettingsViewModel extends AppViewModel<ViewState> {
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
private final Long channelId;
|
|
|
|
private StoreState currentStoreState;
|
|
|
|
private PublishSubject<Event> eventSubject;
|
|
|
|
private final long guildId;
|
|
|
|
private ModelInvite.Settings inviteSettings;
|
|
|
|
private final StoreInviteSettings storeInviteSettings;
|
|
|
|
private Channel targetChannel;
|
|
|
|
private final TargetChannelSelector targetChannelSelector;
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteSettingsViewModel.kt */
|
|
|
|
/* renamed from: com.discord.widgets.guilds.invite.GuildInviteSettingsViewModel$1 reason: invalid class name */
|
|
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
|
|
public final /* synthetic */ GuildInviteSettingsViewModel this$0;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public AnonymousClass1(GuildInviteSettingsViewModel guildInviteSettingsViewModel) {
|
|
|
|
super(1);
|
|
|
|
this.this$0 = guildInviteSettingsViewModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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");
|
|
|
|
GuildInviteSettingsViewModel.access$handleStoreState(this.this$0, storeState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteSettingsViewModel.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, StoreInviteSettings storeInviteSettings) {
|
|
|
|
return companion.observeStoreState(j, storeInviteSettings);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final Observable<StoreState> observeStoreState(long j, StoreInviteSettings storeInviteSettings) {
|
|
|
|
Observable<StoreState> j2 = Observable.j(storeInviteSettings.getInviteSettings(), storeInviteSettings.getInvitableChannels(j), GuildInviteSettingsViewModel$Companion$observeStoreState$1.INSTANCE);
|
|
|
|
m.checkNotNullExpressionValue(j2, "Observable.combineLatest…hannels\n )\n }");
|
|
|
|
return j2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteSettingsViewModel.kt */
|
|
|
|
public static abstract class Event {
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteSettingsViewModel.kt */
|
|
|
|
public static final class InviteCreationFailure extends Event {
|
|
|
|
public static final InviteCreationFailure INSTANCE = new InviteCreationFailure();
|
|
|
|
|
|
|
|
private InviteCreationFailure() {
|
|
|
|
super(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteSettingsViewModel.kt */
|
|
|
|
public static final class InviteCreationSuccess extends Event {
|
|
|
|
private final GuildInvite invite;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public InviteCreationSuccess(GuildInvite guildInvite) {
|
|
|
|
super(null);
|
|
|
|
m.checkNotNullParameter(guildInvite, "invite");
|
|
|
|
this.invite = guildInvite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ InviteCreationSuccess copy$default(InviteCreationSuccess inviteCreationSuccess, GuildInvite guildInvite, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
guildInvite = inviteCreationSuccess.invite;
|
|
|
|
}
|
|
|
|
return inviteCreationSuccess.copy(guildInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final GuildInvite component1() {
|
|
|
|
return this.invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final InviteCreationSuccess copy(GuildInvite guildInvite) {
|
|
|
|
m.checkNotNullParameter(guildInvite, "invite");
|
|
|
|
return new InviteCreationSuccess(guildInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this != obj) {
|
|
|
|
return (obj instanceof InviteCreationSuccess) && m.areEqual(this.invite, ((InviteCreationSuccess) obj).invite);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final GuildInvite getInvite() {
|
|
|
|
return this.invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
GuildInvite guildInvite = this.invite;
|
|
|
|
if (guildInvite != null) {
|
|
|
|
return guildInvite.hashCode();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-08-11 06:37:47 +00:00
|
|
|
StringBuilder L = a.L("InviteCreationSuccess(invite=");
|
|
|
|
L.append(this.invite);
|
|
|
|
L.append(")");
|
|
|
|
return L.toString();
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Event() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteSettingsViewModel.kt */
|
|
|
|
public static final class StoreState {
|
|
|
|
private final Map<Long, Channel> invitableChannels;
|
|
|
|
private final ModelInvite.Settings inviteSettings;
|
|
|
|
|
|
|
|
public StoreState(ModelInvite.Settings settings, Map<Long, Channel> map) {
|
|
|
|
m.checkNotNullParameter(settings, "inviteSettings");
|
|
|
|
m.checkNotNullParameter(map, "invitableChannels");
|
|
|
|
this.inviteSettings = settings;
|
|
|
|
this.invitableChannels = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guilds.invite.GuildInviteSettingsViewModel$StoreState */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, ModelInvite.Settings settings, Map map, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
settings = storeState.inviteSettings;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
map = storeState.invitableChannels;
|
|
|
|
}
|
|
|
|
return storeState.copy(settings, map);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite.Settings component1() {
|
|
|
|
return this.inviteSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Map<Long, Channel> component2() {
|
|
|
|
return this.invitableChannels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final StoreState copy(ModelInvite.Settings settings, Map<Long, Channel> map) {
|
|
|
|
m.checkNotNullParameter(settings, "inviteSettings");
|
|
|
|
m.checkNotNullParameter(map, "invitableChannels");
|
|
|
|
return new StoreState(settings, map);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof StoreState)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
StoreState storeState = (StoreState) obj;
|
|
|
|
return m.areEqual(this.inviteSettings, storeState.inviteSettings) && m.areEqual(this.invitableChannels, storeState.invitableChannels);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Map<Long, Channel> getInvitableChannels() {
|
|
|
|
return this.invitableChannels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite.Settings getInviteSettings() {
|
|
|
|
return this.inviteSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
ModelInvite.Settings settings = this.inviteSettings;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (settings != null ? settings.hashCode() : 0) * 31;
|
|
|
|
Map<Long, Channel> map = this.invitableChannels;
|
|
|
|
if (map != null) {
|
|
|
|
i = map.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-08-11 06:37:47 +00:00
|
|
|
StringBuilder L = a.L("StoreState(inviteSettings=");
|
|
|
|
L.append(this.inviteSettings);
|
|
|
|
L.append(", invitableChannels=");
|
|
|
|
return a.F(L, this.invitableChannels, ")");
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: GuildInviteSettingsViewModel.kt */
|
|
|
|
public static final class ViewState {
|
|
|
|
private final List<Channel> invitableChannels;
|
|
|
|
private final ModelInvite.Settings inviteSettings;
|
|
|
|
private final Channel targetChannel;
|
|
|
|
|
|
|
|
public ViewState(List<Channel> list, ModelInvite.Settings settings, Channel channel) {
|
|
|
|
m.checkNotNullParameter(list, "invitableChannels");
|
|
|
|
m.checkNotNullParameter(settings, "inviteSettings");
|
|
|
|
this.invitableChannels = list;
|
|
|
|
this.inviteSettings = settings;
|
|
|
|
this.targetChannel = channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guilds.invite.GuildInviteSettingsViewModel$ViewState */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public static /* synthetic */ ViewState copy$default(ViewState viewState, List list, ModelInvite.Settings settings, Channel channel, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
list = viewState.invitableChannels;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
settings = viewState.inviteSettings;
|
|
|
|
}
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
channel = viewState.targetChannel;
|
|
|
|
}
|
|
|
|
return viewState.copy(list, settings, channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<Channel> component1() {
|
|
|
|
return this.invitableChannels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite.Settings component2() {
|
|
|
|
return this.inviteSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Channel component3() {
|
|
|
|
return this.targetChannel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ViewState copy(List<Channel> list, ModelInvite.Settings settings, Channel channel) {
|
|
|
|
m.checkNotNullParameter(list, "invitableChannels");
|
|
|
|
m.checkNotNullParameter(settings, "inviteSettings");
|
|
|
|
return new ViewState(list, settings, channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof ViewState)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ViewState viewState = (ViewState) obj;
|
|
|
|
return m.areEqual(this.invitableChannels, viewState.invitableChannels) && m.areEqual(this.inviteSettings, viewState.inviteSettings) && m.areEqual(this.targetChannel, viewState.targetChannel);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<Channel> getInvitableChannels() {
|
|
|
|
return this.invitableChannels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ModelInvite.Settings getInviteSettings() {
|
|
|
|
return this.inviteSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Channel getTargetChannel() {
|
|
|
|
return this.targetChannel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
List<Channel> list = this.invitableChannels;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (list != null ? list.hashCode() : 0) * 31;
|
|
|
|
ModelInvite.Settings settings = this.inviteSettings;
|
|
|
|
int hashCode2 = (hashCode + (settings != null ? settings.hashCode() : 0)) * 31;
|
|
|
|
Channel channel = this.targetChannel;
|
|
|
|
if (channel != null) {
|
|
|
|
i = channel.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode2 + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-08-11 06:37:47 +00:00
|
|
|
StringBuilder L = a.L("ViewState(invitableChannels=");
|
|
|
|
L.append(this.invitableChannels);
|
|
|
|
L.append(", inviteSettings=");
|
|
|
|
L.append(this.inviteSettings);
|
|
|
|
L.append(", targetChannel=");
|
|
|
|
L.append(this.targetChannel);
|
|
|
|
L.append(")");
|
|
|
|
return L.toString();
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public GuildInviteSettingsViewModel(Long l, long j, StoreInviteSettings storeInviteSettings, TargetChannelSelector targetChannelSelector, Observable<StoreState> observable) {
|
|
|
|
super(null, 1, null);
|
|
|
|
m.checkNotNullParameter(storeInviteSettings, "storeInviteSettings");
|
|
|
|
m.checkNotNullParameter(targetChannelSelector, "targetChannelSelector");
|
|
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
|
|
this.channelId = l;
|
|
|
|
this.guildId = j;
|
|
|
|
this.storeInviteSettings = storeInviteSettings;
|
|
|
|
this.targetChannelSelector = targetChannelSelector;
|
|
|
|
PublishSubject<Event> k0 = PublishSubject.k0();
|
|
|
|
m.checkNotNullExpressionValue(k0, "PublishSubject.create()");
|
|
|
|
this.eventSubject = k0;
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), GuildInviteSettingsViewModel.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 */ GuildInviteSettingsViewModel(Long l, long j, StoreInviteSettings storeInviteSettings, TargetChannelSelector targetChannelSelector, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this(l, j, storeInviteSettings, (i & 8) != 0 ? new TargetChannelSelector() : targetChannelSelector, (i & 16) != 0 ? Companion.access$observeStoreState(Companion, j, storeInviteSettings) : observable);
|
|
|
|
storeInviteSettings = (i & 4) != 0 ? StoreStream.Companion.getInviteSettings() : storeInviteSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$handleInviteCreationFailure(GuildInviteSettingsViewModel guildInviteSettingsViewModel) {
|
|
|
|
guildInviteSettingsViewModel.handleInviteCreationFailure();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$handleInviteCreationSuccess(GuildInviteSettingsViewModel guildInviteSettingsViewModel, ModelInvite modelInvite) {
|
|
|
|
guildInviteSettingsViewModel.handleInviteCreationSuccess(modelInvite);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(GuildInviteSettingsViewModel guildInviteSettingsViewModel, StoreState storeState) {
|
|
|
|
guildInviteSettingsViewModel.handleStoreState(storeState);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void generateInviteForChannel(long j) {
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(StoreInviteSettings.generateInvite$default(this.storeInviteSettings, j, null, 2, null), false, 1, null), this, null, 2, null), GuildInviteSettingsViewModel.class, (Context) null, (Function1) null, new GuildInviteSettingsViewModel$generateInviteForChannel$2(this), (Function0) null, (Function0) null, new GuildInviteSettingsViewModel$generateInviteForChannel$1(this), 54, (Object) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
private final void handleInviteCreationFailure() {
|
|
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
|
|
publishSubject.j.onNext(Event.InviteCreationFailure.INSTANCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
private final void handleInviteCreationSuccess(ModelInvite modelInvite) {
|
|
|
|
GuildInvite createFromModelInvite = GuildInvite.Companion.createFromModelInvite(modelInvite);
|
|
|
|
PublishSubject<Event> publishSubject = this.eventSubject;
|
|
|
|
publishSubject.j.onNext(new Event.InviteCreationSuccess(createFromModelInvite));
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
|
|
ModelInvite.Settings settings = this.inviteSettings;
|
|
|
|
if (settings == null) {
|
|
|
|
this.inviteSettings = storeState.getInviteSettings();
|
|
|
|
settings = storeState.getInviteSettings();
|
|
|
|
}
|
|
|
|
Map<Long, Channel> invitableChannels = storeState.getInvitableChannels();
|
|
|
|
Channel channel = this.targetChannel;
|
|
|
|
if (channel == null) {
|
|
|
|
channel = this.targetChannelSelector.getTargetChannel(invitableChannels, this.channelId);
|
|
|
|
this.targetChannel = channel;
|
|
|
|
}
|
|
|
|
updateViewState(new ViewState(u.toList(invitableChannels.values()), settings, channel));
|
|
|
|
this.currentStoreState = storeState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Observable<Event> observeEvents() {
|
|
|
|
return this.eventSubject;
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
public final void saveInviteSettings() {
|
|
|
|
Channel channel;
|
|
|
|
ModelInvite.Settings settings = this.inviteSettings;
|
|
|
|
if (settings != null && (channel = this.targetChannel) != null) {
|
|
|
|
this.storeInviteSettings.setInviteSettings(settings);
|
|
|
|
generateInviteForChannel(channel.h());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
public final void selectChannel(Channel channel) {
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (viewState != null && channel != null) {
|
|
|
|
this.targetChannel = channel;
|
|
|
|
updateViewState(ViewState.copy$default(viewState, null, null, channel, 3, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
public final void updatePendingInviteSettings(ModelInvite.Settings settings) {
|
|
|
|
m.checkNotNullParameter(settings, "settings");
|
|
|
|
ViewState viewState = getViewState();
|
|
|
|
if (viewState != null) {
|
|
|
|
this.inviteSettings = settings;
|
|
|
|
updateViewState(ViewState.copy$default(viewState, null, settings, null, 5, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|