discord-jadx/app/src/main/java/com/discord/widgets/servers/community/WidgetServerSettingsEnableC...

858 lines
38 KiB
Java

package com.discord.widgets.servers.community;
import android.content.Context;
import androidx.annotation.MainThread;
import b.d.b.a.a;
import com.discord.api.channel.Channel;
import com.discord.api.guild.GuildExplicitContentFilter;
import com.discord.api.guild.GuildFeature;
import com.discord.api.guild.GuildVerificationLevel;
import com.discord.api.role.GuildRole;
import com.discord.app.AppViewModel;
import com.discord.models.guild.Guild;
import com.discord.models.user.MeUser;
import com.discord.restapi.RestAPIParams;
import com.discord.stores.StoreChannels;
import com.discord.stores.StoreGuilds;
import com.discord.stores.StorePermissions;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreUser;
import com.discord.utilities.permissions.PermissionUtils;
import com.discord.utilities.rest.RestAPI;
import com.discord.utilities.rx.ObservableExtensionsKt;
import d0.t.u;
import d0.z.d.k;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
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: WidgetServerSettingsEnableCommunityViewModel.kt */
public final class WidgetServerSettingsEnableCommunityViewModel extends AppViewModel<ViewState> {
public static final Companion Companion = new Companion(null);
private final PublishSubject<Event> eventSubject;
private final long guildId;
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
/* renamed from: com.discord.widgets.servers.community.WidgetServerSettingsEnableCommunityViewModel$1 reason: invalid class name */
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<StoreState, Unit> {
public AnonymousClass1(WidgetServerSettingsEnableCommunityViewModel widgetServerSettingsEnableCommunityViewModel) {
super(1, widgetServerSettingsEnableCommunityViewModel, WidgetServerSettingsEnableCommunityViewModel.class, "handleStoreState", "handleStoreState(Lcom/discord/widgets/servers/community/WidgetServerSettingsEnableCommunityViewModel$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");
WidgetServerSettingsEnableCommunityViewModel.access$handleStoreState((WidgetServerSettingsEnableCommunityViewModel) this.receiver, storeState);
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static final class CommunityGuildConfig {
private final boolean defaultMessageNotifications;
private final boolean everyonePermissions;
private final boolean explicitContentFilter;
private final List<GuildFeature> features;
private final Guild guild;
private final boolean isPrivacyPolicyAccepted;
private final Map<Long, GuildRole> roles;
private final Channel rulesChannel;
private final Long rulesChannelId;
private final Channel updatesChannel;
private final Long updatesChannelId;
private final boolean verificationLevel;
/* JADX DEBUG: Multi-variable search result rejected for r12v0, resolved type: java.util.List<? extends com.discord.api.guild.GuildFeature> */
/* JADX WARN: Multi-variable type inference failed */
public CommunityGuildConfig(Channel channel, Channel channel2, Long l, Long l2, boolean z2, boolean z3, boolean z4, boolean z5, Guild guild, boolean z6, List<? extends GuildFeature> list, Map<Long, GuildRole> map) {
m.checkNotNullParameter(list, "features");
this.rulesChannel = channel;
this.updatesChannel = channel2;
this.rulesChannelId = l;
this.updatesChannelId = l2;
this.isPrivacyPolicyAccepted = z2;
this.defaultMessageNotifications = z3;
this.verificationLevel = z4;
this.explicitContentFilter = z5;
this.guild = guild;
this.everyonePermissions = z6;
this.features = list;
this.roles = map;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ CommunityGuildConfig(Channel channel, Channel channel2, Long l, Long l2, boolean z2, boolean z3, boolean z4, boolean z5, Guild guild, boolean z6, List list, Map map, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(channel, channel2, l, l2, z2, z3, z4, z5, guild, z6, (i & 1024) != 0 ? new ArrayList() : list, map);
}
public static /* synthetic */ CommunityGuildConfig copy$default(CommunityGuildConfig communityGuildConfig, Channel channel, Channel channel2, Long l, Long l2, boolean z2, boolean z3, boolean z4, boolean z5, Guild guild, boolean z6, List list, Map map, int i, Object obj) {
return communityGuildConfig.copy((i & 1) != 0 ? communityGuildConfig.rulesChannel : channel, (i & 2) != 0 ? communityGuildConfig.updatesChannel : channel2, (i & 4) != 0 ? communityGuildConfig.rulesChannelId : l, (i & 8) != 0 ? communityGuildConfig.updatesChannelId : l2, (i & 16) != 0 ? communityGuildConfig.isPrivacyPolicyAccepted : z2, (i & 32) != 0 ? communityGuildConfig.defaultMessageNotifications : z3, (i & 64) != 0 ? communityGuildConfig.verificationLevel : z4, (i & 128) != 0 ? communityGuildConfig.explicitContentFilter : z5, (i & 256) != 0 ? communityGuildConfig.guild : guild, (i & 512) != 0 ? communityGuildConfig.everyonePermissions : z6, (i & 1024) != 0 ? communityGuildConfig.features : list, (i & 2048) != 0 ? communityGuildConfig.roles : map);
}
public final Channel component1() {
return this.rulesChannel;
}
public final boolean component10() {
return this.everyonePermissions;
}
public final List<GuildFeature> component11() {
return this.features;
}
public final Map<Long, GuildRole> component12() {
return this.roles;
}
public final Channel component2() {
return this.updatesChannel;
}
public final Long component3() {
return this.rulesChannelId;
}
public final Long component4() {
return this.updatesChannelId;
}
public final boolean component5() {
return this.isPrivacyPolicyAccepted;
}
public final boolean component6() {
return this.defaultMessageNotifications;
}
public final boolean component7() {
return this.verificationLevel;
}
public final boolean component8() {
return this.explicitContentFilter;
}
public final Guild component9() {
return this.guild;
}
public final CommunityGuildConfig copy(Channel channel, Channel channel2, Long l, Long l2, boolean z2, boolean z3, boolean z4, boolean z5, Guild guild, boolean z6, List<? extends GuildFeature> list, Map<Long, GuildRole> map) {
m.checkNotNullParameter(list, "features");
return new CommunityGuildConfig(channel, channel2, l, l2, z2, z3, z4, z5, guild, z6, list, map);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CommunityGuildConfig)) {
return false;
}
CommunityGuildConfig communityGuildConfig = (CommunityGuildConfig) obj;
return m.areEqual(this.rulesChannel, communityGuildConfig.rulesChannel) && m.areEqual(this.updatesChannel, communityGuildConfig.updatesChannel) && m.areEqual(this.rulesChannelId, communityGuildConfig.rulesChannelId) && m.areEqual(this.updatesChannelId, communityGuildConfig.updatesChannelId) && this.isPrivacyPolicyAccepted == communityGuildConfig.isPrivacyPolicyAccepted && this.defaultMessageNotifications == communityGuildConfig.defaultMessageNotifications && this.verificationLevel == communityGuildConfig.verificationLevel && this.explicitContentFilter == communityGuildConfig.explicitContentFilter && m.areEqual(this.guild, communityGuildConfig.guild) && this.everyonePermissions == communityGuildConfig.everyonePermissions && m.areEqual(this.features, communityGuildConfig.features) && m.areEqual(this.roles, communityGuildConfig.roles);
}
public final boolean getDefaultMessageNotifications() {
return this.defaultMessageNotifications;
}
public final boolean getEveryonePermissions() {
return this.everyonePermissions;
}
public final boolean getExplicitContentFilter() {
return this.explicitContentFilter;
}
public final List<GuildFeature> getFeatures() {
return this.features;
}
public final Guild getGuild() {
return this.guild;
}
public final Map<Long, GuildRole> getRoles() {
return this.roles;
}
public final Channel getRulesChannel() {
return this.rulesChannel;
}
public final Long getRulesChannelId() {
return this.rulesChannelId;
}
public final Channel getUpdatesChannel() {
return this.updatesChannel;
}
public final Long getUpdatesChannelId() {
return this.updatesChannelId;
}
public final boolean getVerificationLevel() {
return this.verificationLevel;
}
public int hashCode() {
Channel channel = this.rulesChannel;
int i = 0;
int hashCode = (channel != null ? channel.hashCode() : 0) * 31;
Channel channel2 = this.updatesChannel;
int hashCode2 = (hashCode + (channel2 != null ? channel2.hashCode() : 0)) * 31;
Long l = this.rulesChannelId;
int hashCode3 = (hashCode2 + (l != null ? l.hashCode() : 0)) * 31;
Long l2 = this.updatesChannelId;
int hashCode4 = (hashCode3 + (l2 != null ? l2.hashCode() : 0)) * 31;
boolean z2 = this.isPrivacyPolicyAccepted;
int i2 = 1;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
int i6 = (hashCode4 + i3) * 31;
boolean z3 = this.defaultMessageNotifications;
if (z3) {
z3 = true;
}
int i7 = z3 ? 1 : 0;
int i8 = z3 ? 1 : 0;
int i9 = z3 ? 1 : 0;
int i10 = (i6 + i7) * 31;
boolean z4 = this.verificationLevel;
if (z4) {
z4 = true;
}
int i11 = z4 ? 1 : 0;
int i12 = z4 ? 1 : 0;
int i13 = z4 ? 1 : 0;
int i14 = (i10 + i11) * 31;
boolean z5 = this.explicitContentFilter;
if (z5) {
z5 = true;
}
int i15 = z5 ? 1 : 0;
int i16 = z5 ? 1 : 0;
int i17 = z5 ? 1 : 0;
int i18 = (i14 + i15) * 31;
Guild guild = this.guild;
int hashCode5 = (i18 + (guild != null ? guild.hashCode() : 0)) * 31;
boolean z6 = this.everyonePermissions;
if (!z6) {
i2 = z6 ? 1 : 0;
}
int i19 = (hashCode5 + i2) * 31;
List<GuildFeature> list = this.features;
int hashCode6 = (i19 + (list != null ? list.hashCode() : 0)) * 31;
Map<Long, GuildRole> map = this.roles;
if (map != null) {
i = map.hashCode();
}
return hashCode6 + i;
}
public final boolean isPrivacyPolicyAccepted() {
return this.isPrivacyPolicyAccepted;
}
public String toString() {
StringBuilder R = a.R("CommunityGuildConfig(rulesChannel=");
R.append(this.rulesChannel);
R.append(", updatesChannel=");
R.append(this.updatesChannel);
R.append(", rulesChannelId=");
R.append(this.rulesChannelId);
R.append(", updatesChannelId=");
R.append(this.updatesChannelId);
R.append(", isPrivacyPolicyAccepted=");
R.append(this.isPrivacyPolicyAccepted);
R.append(", defaultMessageNotifications=");
R.append(this.defaultMessageNotifications);
R.append(", verificationLevel=");
R.append(this.verificationLevel);
R.append(", explicitContentFilter=");
R.append(this.explicitContentFilter);
R.append(", guild=");
R.append(this.guild);
R.append(", everyonePermissions=");
R.append(this.everyonePermissions);
R.append(", features=");
R.append(this.features);
R.append(", roles=");
return a.K(R, this.roles, ")");
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private final Observable<StoreState> observeStoreState(long j, StoreGuilds storeGuilds, StoreChannels storeChannels, StorePermissions storePermissions, StoreUser storeUser) {
Observable<R> Y = storeGuilds.observeGuild(j).Y(new WidgetServerSettingsEnableCommunityViewModel$Companion$observeStoreState$1(storeUser, storePermissions, j, storeChannels));
m.checkNotNullExpressionValue(Y, "storeGuilds.observeGuild… }\n }\n }");
return Y;
}
public static /* synthetic */ Observable observeStoreState$default(Companion companion, long j, StoreGuilds storeGuilds, StoreChannels storeChannels, StorePermissions storePermissions, StoreUser storeUser, int i, Object obj) {
if ((i & 2) != 0) {
storeGuilds = StoreStream.Companion.getGuilds();
}
if ((i & 4) != 0) {
storeChannels = StoreStream.Companion.getChannels();
}
if ((i & 8) != 0) {
storePermissions = StoreStream.Companion.getPermissions();
}
if ((i & 16) != 0) {
storeUser = StoreStream.Companion.getUsers();
}
return companion.observeStoreState(j, storeGuilds, storeChannels, storePermissions, storeUser);
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static abstract class Event {
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static final class Error extends Event {
public static final Error INSTANCE = new Error();
private Error() {
super(null);
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static final class SaveSuccess extends Event {
public static final SaveSuccess INSTANCE = new SaveSuccess();
private SaveSuccess() {
super(null);
}
}
private Event() {
}
public /* synthetic */ Event(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static abstract class StoreState {
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static final class Invalid extends StoreState {
public static final Invalid INSTANCE = new Invalid();
private Invalid() {
super(null);
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static final class Valid extends StoreState {
private final Guild guild;
/* renamed from: me reason: collision with root package name */
private final MeUser f2824me;
private final Long permissions;
private final Map<Long, GuildRole> roles;
private final Channel rulesChannel;
private final Channel updatesChannel;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Valid(Guild guild, MeUser meUser, Long l, Map<Long, GuildRole> map, Channel channel, Channel channel2) {
super(null);
m.checkNotNullParameter(guild, "guild");
m.checkNotNullParameter(meUser, "me");
this.guild = guild;
this.f2824me = meUser;
this.permissions = l;
this.roles = map;
this.rulesChannel = channel;
this.updatesChannel = channel2;
}
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: com.discord.widgets.servers.community.WidgetServerSettingsEnableCommunityViewModel$StoreState$Valid */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Valid copy$default(Valid valid, Guild guild, MeUser meUser, Long l, Map map, Channel channel, Channel channel2, int i, Object obj) {
if ((i & 1) != 0) {
guild = valid.guild;
}
if ((i & 2) != 0) {
meUser = valid.f2824me;
}
if ((i & 4) != 0) {
l = valid.permissions;
}
if ((i & 8) != 0) {
map = valid.roles;
}
if ((i & 16) != 0) {
channel = valid.rulesChannel;
}
if ((i & 32) != 0) {
channel2 = valid.updatesChannel;
}
return valid.copy(guild, meUser, l, map, channel, channel2);
}
public final Guild component1() {
return this.guild;
}
public final MeUser component2() {
return this.f2824me;
}
public final Long component3() {
return this.permissions;
}
public final Map<Long, GuildRole> component4() {
return this.roles;
}
public final Channel component5() {
return this.rulesChannel;
}
public final Channel component6() {
return this.updatesChannel;
}
public final Valid copy(Guild guild, MeUser meUser, Long l, Map<Long, GuildRole> map, Channel channel, Channel channel2) {
m.checkNotNullParameter(guild, "guild");
m.checkNotNullParameter(meUser, "me");
return new Valid(guild, meUser, l, map, channel, channel2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Valid)) {
return false;
}
Valid valid = (Valid) obj;
return m.areEqual(this.guild, valid.guild) && m.areEqual(this.f2824me, valid.f2824me) && m.areEqual(this.permissions, valid.permissions) && m.areEqual(this.roles, valid.roles) && m.areEqual(this.rulesChannel, valid.rulesChannel) && m.areEqual(this.updatesChannel, valid.updatesChannel);
}
public final Guild getGuild() {
return this.guild;
}
public final MeUser getMe() {
return this.f2824me;
}
public final Long getPermissions() {
return this.permissions;
}
public final Map<Long, GuildRole> getRoles() {
return this.roles;
}
public final Channel getRulesChannel() {
return this.rulesChannel;
}
public final Channel getUpdatesChannel() {
return this.updatesChannel;
}
public int hashCode() {
Guild guild = this.guild;
int i = 0;
int hashCode = (guild != null ? guild.hashCode() : 0) * 31;
MeUser meUser = this.f2824me;
int hashCode2 = (hashCode + (meUser != null ? meUser.hashCode() : 0)) * 31;
Long l = this.permissions;
int hashCode3 = (hashCode2 + (l != null ? l.hashCode() : 0)) * 31;
Map<Long, GuildRole> map = this.roles;
int hashCode4 = (hashCode3 + (map != null ? map.hashCode() : 0)) * 31;
Channel channel = this.rulesChannel;
int hashCode5 = (hashCode4 + (channel != null ? channel.hashCode() : 0)) * 31;
Channel channel2 = this.updatesChannel;
if (channel2 != null) {
i = channel2.hashCode();
}
return hashCode5 + i;
}
public String toString() {
StringBuilder R = a.R("Valid(guild=");
R.append(this.guild);
R.append(", me=");
R.append(this.f2824me);
R.append(", permissions=");
R.append(this.permissions);
R.append(", roles=");
R.append(this.roles);
R.append(", rulesChannel=");
R.append(this.rulesChannel);
R.append(", updatesChannel=");
R.append(this.updatesChannel);
R.append(")");
return R.toString();
}
}
private StoreState() {
}
public /* synthetic */ StoreState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static abstract class ViewState {
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static final class Invalid extends ViewState {
public static final Invalid INSTANCE = new Invalid();
private Invalid() {
super(null);
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.kt */
public static final class Loaded extends ViewState {
private final CommunityGuildConfig communityGuildConfig;
private final int currentPage;
private final boolean isLoading;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Loaded(int i, boolean z2, CommunityGuildConfig communityGuildConfig) {
super(null);
m.checkNotNullParameter(communityGuildConfig, "communityGuildConfig");
this.currentPage = i;
this.isLoading = z2;
this.communityGuildConfig = communityGuildConfig;
}
public static /* synthetic */ Loaded copy$default(Loaded loaded, int i, boolean z2, CommunityGuildConfig communityGuildConfig, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = loaded.currentPage;
}
if ((i2 & 2) != 0) {
z2 = loaded.isLoading;
}
if ((i2 & 4) != 0) {
communityGuildConfig = loaded.communityGuildConfig;
}
return loaded.copy(i, z2, communityGuildConfig);
}
public final int component1() {
return this.currentPage;
}
public final boolean component2() {
return this.isLoading;
}
public final CommunityGuildConfig component3() {
return this.communityGuildConfig;
}
public final Loaded copy(int i, boolean z2, CommunityGuildConfig communityGuildConfig) {
m.checkNotNullParameter(communityGuildConfig, "communityGuildConfig");
return new Loaded(i, z2, communityGuildConfig);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Loaded)) {
return false;
}
Loaded loaded = (Loaded) obj;
return this.currentPage == loaded.currentPage && this.isLoading == loaded.isLoading && m.areEqual(this.communityGuildConfig, loaded.communityGuildConfig);
}
public final CommunityGuildConfig getCommunityGuildConfig() {
return this.communityGuildConfig;
}
public final int getCurrentPage() {
return this.currentPage;
}
public int hashCode() {
int i = this.currentPage * 31;
boolean z2 = this.isLoading;
if (z2) {
z2 = true;
}
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = (i + i2) * 31;
CommunityGuildConfig communityGuildConfig = this.communityGuildConfig;
return i5 + (communityGuildConfig != null ? communityGuildConfig.hashCode() : 0);
}
public final boolean isLoading() {
return this.isLoading;
}
public String toString() {
StringBuilder R = a.R("Loaded(currentPage=");
R.append(this.currentPage);
R.append(", isLoading=");
R.append(this.isLoading);
R.append(", communityGuildConfig=");
R.append(this.communityGuildConfig);
R.append(")");
return R.toString();
}
}
/* compiled from: WidgetServerSettingsEnableCommunityViewModel.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 WidgetServerSettingsEnableCommunityViewModel(long j, Observable<StoreState> observable) {
super(ViewState.Uninitialized.INSTANCE);
m.checkNotNullParameter(observable, "storeStateObservable");
this.guildId = j;
this.eventSubject = PublishSubject.k0();
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), WidgetServerSettingsEnableCommunityViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ WidgetServerSettingsEnableCommunityViewModel(long j, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(j, (i & 2) != 0 ? Companion.observeStoreState$default(Companion, j, null, null, null, null, 30, null) : observable);
}
public static final /* synthetic */ PublishSubject access$getEventSubject$p(WidgetServerSettingsEnableCommunityViewModel widgetServerSettingsEnableCommunityViewModel) {
return widgetServerSettingsEnableCommunityViewModel.eventSubject;
}
public static final /* synthetic */ void access$handleGuildUpdateError(WidgetServerSettingsEnableCommunityViewModel widgetServerSettingsEnableCommunityViewModel) {
widgetServerSettingsEnableCommunityViewModel.handleGuildUpdateError();
}
public static final /* synthetic */ void access$handleStoreState(WidgetServerSettingsEnableCommunityViewModel widgetServerSettingsEnableCommunityViewModel, StoreState storeState) {
widgetServerSettingsEnableCommunityViewModel.handleStoreState(storeState);
}
public static final /* synthetic */ void access$patchRole(WidgetServerSettingsEnableCommunityViewModel widgetServerSettingsEnableCommunityViewModel, RestAPIParams.Role role) {
widgetServerSettingsEnableCommunityViewModel.patchRole(role);
}
public static final /* synthetic */ void access$updateViewState(WidgetServerSettingsEnableCommunityViewModel widgetServerSettingsEnableCommunityViewModel, ViewState viewState) {
widgetServerSettingsEnableCommunityViewModel.updateViewState(viewState);
}
@MainThread
private final RestAPIParams.UpdateGuild getUpdatedGuildParams() {
GuildVerificationLevel guildVerificationLevel;
GuildVerificationLevel guildVerificationLevel2;
GuildExplicitContentFilter guildExplicitContentFilter;
GuildExplicitContentFilter guildExplicitContentFilter2;
ViewState viewState = getViewState();
if (!(viewState instanceof ViewState.Loaded)) {
viewState = null;
}
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
if (loaded == null) {
return new RestAPIParams.UpdateGuild(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 32767, null);
}
CommunityGuildConfig communityGuildConfig = loaded.getCommunityGuildConfig();
List plus = u.plus((Collection<? extends GuildFeature>) communityGuildConfig.getFeatures(), GuildFeature.COMMUNITY);
Guild guild = communityGuildConfig.getGuild();
if (guild == null || (guildVerificationLevel = guild.getVerificationLevel()) == null) {
guildVerificationLevel = GuildVerificationLevel.NONE;
}
GuildVerificationLevel guildVerificationLevel3 = GuildVerificationLevel.NONE;
if (guildVerificationLevel.compareTo(guildVerificationLevel3) <= 0 || communityGuildConfig.getVerificationLevel()) {
if (guildVerificationLevel == guildVerificationLevel3 && communityGuildConfig.getVerificationLevel()) {
guildVerificationLevel = GuildVerificationLevel.LOW;
}
guildVerificationLevel2 = guildVerificationLevel;
} else {
guildVerificationLevel2 = guildVerificationLevel3;
}
Guild guild2 = communityGuildConfig.getGuild();
if (guild2 == null || (guildExplicitContentFilter = guild2.getExplicitContentFilter()) == null) {
guildExplicitContentFilter = GuildExplicitContentFilter.NONE;
}
GuildExplicitContentFilter guildExplicitContentFilter3 = GuildExplicitContentFilter.NONE;
if (guildExplicitContentFilter.compareTo(guildExplicitContentFilter3) <= 0 || communityGuildConfig.getExplicitContentFilter()) {
if (guildExplicitContentFilter == guildExplicitContentFilter3 && communityGuildConfig.getExplicitContentFilter()) {
guildExplicitContentFilter = GuildExplicitContentFilter.ALL;
}
guildExplicitContentFilter2 = guildExplicitContentFilter;
} else {
guildExplicitContentFilter2 = guildExplicitContentFilter3;
}
boolean defaultMessageNotifications = communityGuildConfig.getDefaultMessageNotifications();
int i = 1;
if (!defaultMessageNotifications) {
if (!defaultMessageNotifications) {
i = 0;
} else {
throw new NoWhenBranchMatchedException();
}
}
return new RestAPIParams.UpdateGuild(null, null, null, Integer.valueOf(i), null, null, guildVerificationLevel2, guildExplicitContentFilter2, null, null, null, plus, communityGuildConfig.getRulesChannelId(), communityGuildConfig.getUpdatesChannelId(), null, 18231, null);
}
private final void handleGuildUpdateError() {
ViewState viewState = getViewState();
if (!(viewState instanceof ViewState.Loaded)) {
viewState = null;
}
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
if (loaded != null) {
updateViewState(ViewState.Loaded.copy$default(loaded, 0, false, null, 5, null));
PublishSubject<Event> publishSubject = this.eventSubject;
publishSubject.k.onNext(Event.Error.INSTANCE);
}
}
private final void handleStoreState(StoreState storeState) {
GuildRole guildRole;
GuildRole guildRole2;
if (!(storeState instanceof StoreState.Valid)) {
updateViewState(ViewState.Invalid.INSTANCE);
return;
}
StoreState.Valid valid = (StoreState.Valid) storeState;
Guild guild = valid.getGuild();
MeUser me2 = valid.getMe();
if (!(guild.isOwner(me2.getId()) || PermissionUtils.canAndIsElevated(32, valid.getPermissions(), me2.getMfaEnabled(), guild.getMfaLevel()))) {
updateViewState(ViewState.Invalid.INSTANCE);
return;
}
Channel rulesChannel = valid.getRulesChannel();
Channel updatesChannel = valid.getUpdatesChannel();
boolean z2 = guild.getDefaultMessageNotifications() == 1;
boolean z3 = guild.getVerificationLevel().compareTo(GuildVerificationLevel.NONE) > 0;
boolean z4 = guild.getExplicitContentFilter().compareTo(GuildExplicitContentFilter.NONE) > 0;
Map<Long, GuildRole> roles = valid.getRoles();
long h = -1116960071743L & ((roles == null || (guildRole2 = roles.get(Long.valueOf(this.guildId))) == null) ? 0 : guildRole2.h());
Map<Long, GuildRole> roles2 = valid.getRoles();
updateViewState(new ViewState.Loaded(0, false, new CommunityGuildConfig(rulesChannel, updatesChannel, 1L, 1L, false, z2, z3, z4, guild, (roles2 == null || (guildRole = roles2.get(Long.valueOf(this.guildId))) == null || h != guildRole.h()) ? false : true, u.toList(guild.getFeatures()), valid.getRoles())));
}
private final void patchRole(RestAPIParams.Role role) {
ViewState viewState = getViewState();
if (!(viewState instanceof ViewState.Loaded)) {
viewState = null;
}
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
if (loaded != null) {
RestAPI api = RestAPI.Companion.getApi();
long j = this.guildId;
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(api.updateRole(j, j, role), false, 1, null), this, null, 2, null), WidgetServerSettingsEnableCommunityViewModel.class, (Context) null, (Function1) null, new WidgetServerSettingsEnableCommunityViewModel$patchRole$1(this), (Function0) null, (Function0) null, new WidgetServerSettingsEnableCommunityViewModel$patchRole$2(this, loaded), 54, (Object) null);
}
}
public final long getGuildId() {
return this.guildId;
}
@MainThread
public final void goBackToPreviousPage() {
ViewState viewState = getViewState();
if (!(viewState instanceof ViewState.Loaded)) {
viewState = null;
}
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
if (loaded != null) {
updateCurrentPage(loaded.getCurrentPage() - 1);
}
}
@MainThread
public final void modifyGuildConfig(Function1<? super CommunityGuildConfig, CommunityGuildConfig> function1) {
m.checkNotNullParameter(function1, "transform");
ViewState viewState = getViewState();
if (!(viewState instanceof ViewState.Loaded)) {
viewState = null;
}
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
if (loaded != null) {
updateViewState(ViewState.Loaded.copy$default(loaded, 0, false, function1.invoke(loaded.getCommunityGuildConfig()), 3, null));
}
}
public final Observable<Event> observeEvents() {
PublishSubject<Event> publishSubject = this.eventSubject;
m.checkNotNullExpressionValue(publishSubject, "eventSubject");
return publishSubject;
}
@MainThread
public final void updateCurrentPage(int i) {
ViewState viewState = getViewState();
if (!(viewState instanceof ViewState.Loaded)) {
viewState = null;
}
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
if (loaded != null) {
updateViewState(ViewState.Loaded.copy$default(loaded, i, false, null, 6, null));
}
}
public final void updateGuild() {
ViewState viewState = getViewState();
if (!(viewState instanceof ViewState.Loaded)) {
viewState = null;
}
ViewState.Loaded loaded = (ViewState.Loaded) viewState;
if (loaded != null) {
CommunityGuildConfig communityGuildConfig = loaded.getCommunityGuildConfig();
updateViewState(ViewState.Loaded.copy$default(loaded, 0, true, null, 5, null));
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().updateGuild(this.guildId, getUpdatedGuildParams()), false, 1, null), this, null, 2, null), WidgetServerSettingsEnableCommunityViewModel.class, (Context) null, (Function1) null, new WidgetServerSettingsEnableCommunityViewModel$updateGuild$1(this), (Function0) null, (Function0) null, new WidgetServerSettingsEnableCommunityViewModel$updateGuild$2(this, communityGuildConfig, loaded), 54, (Object) null);
}
}
}