discord-jadx/app/src/main/java/com/discord/widgets/guildscheduledevent/GuildScheduledEventListView...

422 lines
20 KiB
Java

package com.discord.widgets.guildscheduledevent;
import android.content.Context;
import c.d.b.a.a;
import com.discord.api.channel.Channel;
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
import com.discord.api.guildscheduledevent.GuildScheduledEventStatus;
import com.discord.api.permission.Permission;
import com.discord.api.role.GuildRole;
import com.discord.app.AppViewModel;
import com.discord.stores.StoreChannels;
import com.discord.stores.StoreGuildScheduledEvents;
import com.discord.stores.StoreGuilds;
import com.discord.stores.StorePermissions;
import com.discord.stores.StoreStream;
import com.discord.stores.updates.ObservationDeck;
import com.discord.stores.updates.ObservationDeckProvider;
import com.discord.utilities.analytics.AnalyticsTracker;
import com.discord.utilities.permissions.PermissionUtils;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.widgets.guildscheduledevent.GuildScheduledEventListItem;
import d0.t.h0;
import d0.t.o;
import d0.z.d.k;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.Comparator;
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;
/* compiled from: GuildScheduledEventListViewModel.kt */
public final class GuildScheduledEventListViewModel extends AppViewModel<ViewState> {
public static final Companion Companion = new Companion(null);
private final StoreChannels channelsStore;
private final long guildId;
private final StoreGuildScheduledEvents guildScheduledEventsStore;
private final StoreGuilds guildsStore;
private final StorePermissions permissionsStore;
/* compiled from: GuildScheduledEventListViewModel.kt */
/* renamed from: com.discord.widgets.guildscheduledevent.GuildScheduledEventListViewModel$1 reason: invalid class name */
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<StoreState, Unit> {
public AnonymousClass1(GuildScheduledEventListViewModel guildScheduledEventListViewModel) {
super(1, guildScheduledEventListViewModel, GuildScheduledEventListViewModel.class, "handleStoreState", "handleStoreState(Lcom/discord/widgets/guildscheduledevent/GuildScheduledEventListViewModel$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");
GuildScheduledEventListViewModel.access$handleStoreState((GuildScheduledEventListViewModel) this.receiver, storeState);
}
}
/* compiled from: GuildScheduledEventListViewModel.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ Observable access$observeStores(Companion companion, long j, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreChannels storeChannels, StorePermissions storePermissions, StoreGuilds storeGuilds) {
return companion.observeStores(j, storeGuildScheduledEvents, storeChannels, storePermissions, storeGuilds);
}
private final Observable<StoreState> observeStores(long j, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreChannels storeChannels, StorePermissions storePermissions, StoreGuilds storeGuilds) {
return ObservationDeck.connectRx$default(ObservationDeckProvider.get(), new ObservationDeck.UpdateSource[]{storeGuildScheduledEvents, storeChannels, storePermissions, storeGuilds}, false, null, null, new GuildScheduledEventListViewModel$Companion$observeStores$1(storeChannels, j, storeGuildScheduledEvents, storePermissions, storeGuilds), 14, null);
}
}
/* compiled from: GuildScheduledEventListViewModel.kt */
public static final class GuildScheduledEventsComparator implements Comparator<GuildScheduledEvent> {
public static final GuildScheduledEventsComparator INSTANCE = new GuildScheduledEventsComparator();
private GuildScheduledEventsComparator() {
}
/* JADX WARNING: Code restructure failed: missing block: B:9:0x0017, code lost:
if ((r7 != null ? r7.h() : null) != r2) goto L_0x0019;
*/
public int compare(GuildScheduledEvent guildScheduledEvent, GuildScheduledEvent guildScheduledEvent2) {
GuildScheduledEventStatus guildScheduledEventStatus = null;
GuildScheduledEventStatus h = guildScheduledEvent != null ? guildScheduledEvent.h() : null;
GuildScheduledEventStatus guildScheduledEventStatus2 = GuildScheduledEventStatus.ACTIVE;
if (h == guildScheduledEventStatus2) {
}
if ((guildScheduledEvent != null ? guildScheduledEvent.h() : null) != guildScheduledEventStatus2) {
if (guildScheduledEvent2 != null) {
guildScheduledEventStatus = guildScheduledEvent2.h();
}
if (guildScheduledEventStatus == guildScheduledEventStatus2) {
return 1;
}
}
if (guildScheduledEvent != null && guildScheduledEvent2 != null) {
return guildScheduledEvent.g().compareTo(guildScheduledEvent2.g());
}
if (guildScheduledEvent == null) {
return 1;
}
return guildScheduledEvent2 == null ? -1 : 0;
}
}
/* compiled from: GuildScheduledEventListViewModel.kt */
public static final class StoreState {
private final boolean canCreateEvents;
private final Map<Long, Long> guildChannelPermissions;
private final Map<Long, Channel> guildChannels;
private final Map<Long, GuildRole> guildRoles;
private final List<GuildScheduledEvent> guildScheduledEvents;
private final Map<Long, GuildScheduledEvent> userGuildScheduledEvents;
public StoreState(List<GuildScheduledEvent> list, Map<Long, GuildScheduledEvent> map, Map<Long, Channel> map2, Map<Long, Long> map3, boolean z2, Map<Long, GuildRole> map4) {
m.checkNotNullParameter(list, "guildScheduledEvents");
m.checkNotNullParameter(map, "userGuildScheduledEvents");
m.checkNotNullParameter(map2, "guildChannels");
m.checkNotNullParameter(map3, "guildChannelPermissions");
m.checkNotNullParameter(map4, "guildRoles");
this.guildScheduledEvents = list;
this.userGuildScheduledEvents = map;
this.guildChannels = map2;
this.guildChannelPermissions = map3;
this.canCreateEvents = z2;
this.guildRoles = map4;
}
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: com.discord.widgets.guildscheduledevent.GuildScheduledEventListViewModel$StoreState */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ StoreState copy$default(StoreState storeState, List list, Map map, Map map2, Map map3, boolean z2, Map map4, int i, Object obj) {
if ((i & 1) != 0) {
list = storeState.guildScheduledEvents;
}
if ((i & 2) != 0) {
map = storeState.userGuildScheduledEvents;
}
if ((i & 4) != 0) {
map2 = storeState.guildChannels;
}
if ((i & 8) != 0) {
map3 = storeState.guildChannelPermissions;
}
if ((i & 16) != 0) {
z2 = storeState.canCreateEvents;
}
if ((i & 32) != 0) {
map4 = storeState.guildRoles;
}
return storeState.copy(list, map, map2, map3, z2, map4);
}
public final List<GuildScheduledEvent> component1() {
return this.guildScheduledEvents;
}
public final Map<Long, GuildScheduledEvent> component2() {
return this.userGuildScheduledEvents;
}
public final Map<Long, Channel> component3() {
return this.guildChannels;
}
public final Map<Long, Long> component4() {
return this.guildChannelPermissions;
}
public final boolean component5() {
return this.canCreateEvents;
}
public final Map<Long, GuildRole> component6() {
return this.guildRoles;
}
public final StoreState copy(List<GuildScheduledEvent> list, Map<Long, GuildScheduledEvent> map, Map<Long, Channel> map2, Map<Long, Long> map3, boolean z2, Map<Long, GuildRole> map4) {
m.checkNotNullParameter(list, "guildScheduledEvents");
m.checkNotNullParameter(map, "userGuildScheduledEvents");
m.checkNotNullParameter(map2, "guildChannels");
m.checkNotNullParameter(map3, "guildChannelPermissions");
m.checkNotNullParameter(map4, "guildRoles");
return new StoreState(list, map, map2, map3, z2, map4);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof StoreState)) {
return false;
}
StoreState storeState = (StoreState) obj;
return m.areEqual(this.guildScheduledEvents, storeState.guildScheduledEvents) && m.areEqual(this.userGuildScheduledEvents, storeState.userGuildScheduledEvents) && m.areEqual(this.guildChannels, storeState.guildChannels) && m.areEqual(this.guildChannelPermissions, storeState.guildChannelPermissions) && this.canCreateEvents == storeState.canCreateEvents && m.areEqual(this.guildRoles, storeState.guildRoles);
}
public final boolean getCanCreateEvents() {
return this.canCreateEvents;
}
public final Map<Long, Long> getGuildChannelPermissions() {
return this.guildChannelPermissions;
}
public final Map<Long, Channel> getGuildChannels() {
return this.guildChannels;
}
public final Map<Long, GuildRole> getGuildRoles() {
return this.guildRoles;
}
public final List<GuildScheduledEvent> getGuildScheduledEvents() {
return this.guildScheduledEvents;
}
public final Map<Long, GuildScheduledEvent> getUserGuildScheduledEvents() {
return this.userGuildScheduledEvents;
}
public int hashCode() {
List<GuildScheduledEvent> list = this.guildScheduledEvents;
int i = 0;
int hashCode = (list != null ? list.hashCode() : 0) * 31;
Map<Long, GuildScheduledEvent> map = this.userGuildScheduledEvents;
int hashCode2 = (hashCode + (map != null ? map.hashCode() : 0)) * 31;
Map<Long, Channel> map2 = this.guildChannels;
int hashCode3 = (hashCode2 + (map2 != null ? map2.hashCode() : 0)) * 31;
Map<Long, Long> map3 = this.guildChannelPermissions;
int hashCode4 = (hashCode3 + (map3 != null ? map3.hashCode() : 0)) * 31;
boolean z2 = this.canCreateEvents;
if (z2) {
z2 = true;
}
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = (hashCode4 + i2) * 31;
Map<Long, GuildRole> map4 = this.guildRoles;
if (map4 != null) {
i = map4.hashCode();
}
return i5 + i;
}
public String toString() {
StringBuilder L = a.L("StoreState(guildScheduledEvents=");
L.append(this.guildScheduledEvents);
L.append(", userGuildScheduledEvents=");
L.append(this.userGuildScheduledEvents);
L.append(", guildChannels=");
L.append(this.guildChannels);
L.append(", guildChannelPermissions=");
L.append(this.guildChannelPermissions);
L.append(", canCreateEvents=");
L.append(this.canCreateEvents);
L.append(", guildRoles=");
return a.F(L, this.guildRoles, ")");
}
}
/* compiled from: GuildScheduledEventListViewModel.kt */
public static abstract class ViewState {
/* compiled from: GuildScheduledEventListViewModel.kt */
public static final class Initial extends ViewState {
public static final Initial INSTANCE = new Initial();
private Initial() {
super(null);
}
}
/* compiled from: GuildScheduledEventListViewModel.kt */
public static final class Loaded extends ViewState {
private final boolean canCreateEvents;
private final List<GuildScheduledEventListItem.Event> guildScheduledEvents;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Loaded(List<GuildScheduledEventListItem.Event> list, boolean z2) {
super(null);
m.checkNotNullParameter(list, "guildScheduledEvents");
this.guildScheduledEvents = list;
this.canCreateEvents = z2;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guildscheduledevent.GuildScheduledEventListViewModel$ViewState$Loaded */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Loaded copy$default(Loaded loaded, List list, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
list = loaded.guildScheduledEvents;
}
if ((i & 2) != 0) {
z2 = loaded.canCreateEvents;
}
return loaded.copy(list, z2);
}
public final List<GuildScheduledEventListItem.Event> component1() {
return this.guildScheduledEvents;
}
public final boolean component2() {
return this.canCreateEvents;
}
public final Loaded copy(List<GuildScheduledEventListItem.Event> list, boolean z2) {
m.checkNotNullParameter(list, "guildScheduledEvents");
return new Loaded(list, 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.guildScheduledEvents, loaded.guildScheduledEvents) && this.canCreateEvents == loaded.canCreateEvents;
}
public final boolean getCanCreateEvents() {
return this.canCreateEvents;
}
public final List<GuildScheduledEventListItem.Event> getGuildScheduledEvents() {
return this.guildScheduledEvents;
}
public int hashCode() {
List<GuildScheduledEventListItem.Event> list = this.guildScheduledEvents;
int hashCode = (list != null ? list.hashCode() : 0) * 31;
boolean z2 = this.canCreateEvents;
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() {
StringBuilder L = a.L("Loaded(guildScheduledEvents=");
L.append(this.guildScheduledEvents);
L.append(", canCreateEvents=");
return a.G(L, this.canCreateEvents, ")");
}
}
private ViewState() {
}
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public GuildScheduledEventListViewModel(long j, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreChannels storeChannels, StorePermissions storePermissions, StoreGuilds storeGuilds, Observable<StoreState> observable) {
super(ViewState.Initial.INSTANCE);
m.checkNotNullParameter(storeGuildScheduledEvents, "guildScheduledEventsStore");
m.checkNotNullParameter(storeChannels, "channelsStore");
m.checkNotNullParameter(storePermissions, "permissionsStore");
m.checkNotNullParameter(storeGuilds, "guildsStore");
m.checkNotNullParameter(observable, "storeStateObservable");
this.guildId = j;
this.guildScheduledEventsStore = storeGuildScheduledEvents;
this.channelsStore = storeChannels;
this.permissionsStore = storePermissions;
this.guildsStore = storeGuilds;
storeGuildScheduledEvents.fetchGuildScheduledEventUserCounts(j);
storeGuildScheduledEvents.fetchUserGuildScheduledEvents();
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), GuildScheduledEventListViewModel.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 */ GuildScheduledEventListViewModel(long j, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreChannels storeChannels, StorePermissions storePermissions, StoreGuilds storeGuilds, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(j, r4, r5, r6, r7, (i & 32) != 0 ? Companion.access$observeStores(Companion, j, r4, r5, r6, r7) : observable);
StoreGuildScheduledEvents guildScheduledEvents = (i & 2) != 0 ? StoreStream.Companion.getGuildScheduledEvents() : storeGuildScheduledEvents;
StoreChannels channels = (i & 4) != 0 ? StoreStream.Companion.getChannels() : storeChannels;
StorePermissions permissions = (i & 8) != 0 ? StoreStream.Companion.getPermissions() : storePermissions;
StoreGuilds guilds = (i & 16) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds;
}
public static final /* synthetic */ void access$handleStoreState(GuildScheduledEventListViewModel guildScheduledEventListViewModel, StoreState storeState) {
guildScheduledEventListViewModel.handleStoreState(storeState);
}
private final void handleStoreState(StoreState storeState) {
if (!(getViewState() instanceof ViewState.Loaded)) {
AnalyticsTracker.INSTANCE.openGuildScheduledEventSheet(this.guildId, storeState.getGuildScheduledEvents().size());
}
List<GuildScheduledEvent> guildScheduledEvents = storeState.getGuildScheduledEvents();
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(guildScheduledEvents, 10));
for (GuildScheduledEvent guildScheduledEvent : guildScheduledEvents) {
Channel channel = (Channel) h0.getValue(storeState.getGuildChannels(), Long.valueOf(guildScheduledEvent.b()));
boolean contains = storeState.getUserGuildScheduledEvents().keySet().contains(Long.valueOf(guildScheduledEvent.e()));
Long l = storeState.getGuildChannelPermissions().get(Long.valueOf(guildScheduledEvent.b()));
arrayList.add(new GuildScheduledEventListItem.Event(guildScheduledEvent, channel, contains, l != null ? PermissionUtils.can(Permission.START_STAGE_EVENT, Long.valueOf(l.longValue())) : false, PermissionUtils.INSTANCE.canEveryoneRole(Permission.VIEW_CHANNEL, channel, storeState.getGuildRoles())));
}
updateViewState(new ViewState.Loaded(arrayList, storeState.getCanCreateEvents()));
}
public final void toggleRsvp(GuildScheduledEvent guildScheduledEvent) {
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
this.guildScheduledEventsStore.toggleRsvpGuildScheduledEvent(guildScheduledEvent);
}
}