139 lines
8.2 KiB
Java
139 lines
8.2 KiB
Java
package com.discord.widgets.guildscheduledevent;
|
|
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.directory.DirectoryEntryEvent;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
|
|
import com.discord.api.permission.Permission;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.guild.UserGuildMember;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreDirectories;
|
|
import com.discord.stores.StoreGuildScheduledEvents;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StorePermissions;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.stores.StoreUserSettings;
|
|
import com.discord.stores.StoreVoiceChannelSelected;
|
|
import com.discord.stores.utilities.RestCallState;
|
|
import com.discord.utilities.guildscheduledevent.GuildScheduledEventUtilities;
|
|
import com.discord.utilities.guildscheduledevent.GuildScheduledEventUtilitiesKt;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.widgets.guildscheduledevent.GuildScheduledEventDetailsViewModel;
|
|
import d0.f0.q;
|
|
import d0.t.u;
|
|
import d0.z.d.o;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.jvm.functions.Function0;
|
|
/* compiled from: GuildScheduledEventDetailsViewModel.kt */
|
|
/* loaded from: classes2.dex */
|
|
public final class GuildScheduledEventDetailsViewModel$Companion$observeStores$1 extends o implements Function0<GuildScheduledEventDetailsViewModel.StoreState> {
|
|
public final /* synthetic */ GuildScheduledEventDetailsArgs $args;
|
|
public final /* synthetic */ StoreChannels $channelsStore;
|
|
public final /* synthetic */ StoreDirectories $directoriesStore;
|
|
public final /* synthetic */ StoreGuildScheduledEvents $guildScheduledEventsStore;
|
|
public final /* synthetic */ StoreGuilds $guildsStore;
|
|
public final /* synthetic */ StorePermissions $permissionsStore;
|
|
public final /* synthetic */ StoreVoiceChannelSelected $selectedVoiceChannelStore;
|
|
public final /* synthetic */ StoreUserSettings $userSettingsStore;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public GuildScheduledEventDetailsViewModel$Companion$observeStores$1(GuildScheduledEventDetailsArgs guildScheduledEventDetailsArgs, StoreDirectories storeDirectories, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreGuilds storeGuilds, StoreChannels storeChannels, StoreVoiceChannelSelected storeVoiceChannelSelected, StorePermissions storePermissions, StoreUserSettings storeUserSettings) {
|
|
super(0);
|
|
this.$args = guildScheduledEventDetailsArgs;
|
|
this.$directoriesStore = storeDirectories;
|
|
this.$guildScheduledEventsStore = storeGuildScheduledEvents;
|
|
this.$guildsStore = storeGuilds;
|
|
this.$channelsStore = storeChannels;
|
|
this.$selectedVoiceChannelStore = storeVoiceChannelSelected;
|
|
this.$permissionsStore = storePermissions;
|
|
this.$userSettingsStore = storeUserSettings;
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
/* JADX WARN: Removed duplicated region for block: B:30:0x007e */
|
|
/* JADX WARN: Removed duplicated region for block: B:57:0x0182 */
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
*/
|
|
public final GuildScheduledEventDetailsViewModel.StoreState invoke() {
|
|
GuildScheduledEvent guildScheduledEvent;
|
|
Guild guild;
|
|
List<DirectoryEntryEvent> invoke;
|
|
Object obj;
|
|
boolean z2;
|
|
int ordinal = this.$args.getSource().ordinal();
|
|
Channel channel = null;
|
|
if (ordinal == 0) {
|
|
guildScheduledEvent = StoreGuildScheduledEvents.findEventFromStore$default(this.$guildScheduledEventsStore, this.$args.getEventId(), null, 2, null);
|
|
} else if (ordinal == 1) {
|
|
Long channelId = this.$args.getChannelId();
|
|
if (channelId != null) {
|
|
RestCallState<List<DirectoryEntryEvent>> guildScheduledEventsForChannel = this.$directoriesStore.getGuildScheduledEventsForChannel(channelId.longValue());
|
|
if (!(guildScheduledEventsForChannel == null || (invoke = guildScheduledEventsForChannel.invoke()) == null)) {
|
|
Iterator<T> it = invoke.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (((DirectoryEntryEvent) obj).a().i() == this.$args.getEventId()) {
|
|
z2 = true;
|
|
continue;
|
|
} else {
|
|
z2 = false;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
break;
|
|
}
|
|
}
|
|
DirectoryEntryEvent directoryEntryEvent = (DirectoryEntryEvent) obj;
|
|
if (directoryEntryEvent != null) {
|
|
guildScheduledEvent = directoryEntryEvent.a();
|
|
}
|
|
}
|
|
guildScheduledEvent = null;
|
|
} else {
|
|
guildScheduledEvent = null;
|
|
if (guildScheduledEvent != null) {
|
|
return new GuildScheduledEventDetailsViewModel.StoreState(null, null, null, null, false, false, false, false, false, null, false, null, false, false, 16383, null);
|
|
}
|
|
int ordinal2 = this.$args.getSource().ordinal();
|
|
if (ordinal2 == 0) {
|
|
guild = this.$guildsStore.getGuild(guildScheduledEvent.h());
|
|
} else if (ordinal2 == 1) {
|
|
com.discord.api.guild.Guild g = guildScheduledEvent.g();
|
|
guild = g != null ? new Guild(g) : null;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
boolean z3 = this.$guildsStore.getGuild(guildScheduledEvent.h()) != null;
|
|
UserGuildMember userGuildMember = GuildScheduledEventUtilitiesKt.getCreatorUserGuildMember$default(guildScheduledEvent, (StoreGuilds) null, (StoreUser) null, 3, (Object) null);
|
|
if (!z3) {
|
|
userGuildMember = null;
|
|
}
|
|
List list = q.toList(q.map(u.asSequence(this.$guildScheduledEventsStore.getGuildScheduledEventUsers(guildScheduledEvent.i()).values()), new GuildScheduledEventDetailsViewModel$Companion$observeStores$1$rsvpUsers$1(guildScheduledEvent)));
|
|
Long b2 = guildScheduledEvent.b();
|
|
if (b2 != null) {
|
|
channel = this.$channelsStore.getChannel(b2.longValue());
|
|
}
|
|
Long valueOf = Long.valueOf(this.$selectedVoiceChannelStore.getSelectedVoiceChannelId());
|
|
boolean isMeRsvpedToEvent = this.$guildScheduledEventsStore.isMeRsvpedToEvent(guildScheduledEvent.h(), this.$args.getEventId());
|
|
GuildScheduledEventUtilities.Companion companion = GuildScheduledEventUtilities.Companion;
|
|
boolean canShareEvent$default = GuildScheduledEventUtilities.Companion.canShareEvent$default(companion, guildScheduledEvent.b(), guildScheduledEvent.h(), this.$channelsStore, this.$guildsStore, null, null, 48, null);
|
|
boolean canStartEvent = companion.canStartEvent(guildScheduledEvent.h(), guildScheduledEvent.b(), this.$channelsStore, this.$permissionsStore);
|
|
Long b3 = guildScheduledEvent.b();
|
|
return new GuildScheduledEventDetailsViewModel.StoreState(guildScheduledEvent, channel, guild, userGuildMember, z3, isMeRsvpedToEvent, canShareEvent$default, canStartEvent, this.$userSettingsStore.getIsDeveloperMode(), valueOf, b3 != null ? PermissionUtils.can(Permission.CONNECT, this.$permissionsStore.getPermissionsByChannel().get(Long.valueOf(b3.longValue()))) : false, list, this.$guildScheduledEventsStore.getIsFetchingGuildScheduledEventUsers(), this.$guildScheduledEventsStore.getIsGuildScheduledEventUsersError());
|
|
}
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
if (guildScheduledEvent != null) {
|
|
}
|
|
}
|
|
}
|