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

354 lines
17 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.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.guildscheduledevent.GuildScheduledEventUtilities;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.widgets.guildscheduledevent.GuildScheduledEventListItem;
import d0.t.o;
import d0.z.d.k;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 Long channelId;
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, Long l, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreChannels storeChannels, StorePermissions storePermissions, StoreGuilds storeGuilds) {
return companion.observeStores(j, l, storeGuildScheduledEvents, storeChannels, storePermissions, storeGuilds);
}
private final Observable<StoreState> observeStores(long j, Long l, 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, l, storePermissions), 14, null);
}
}
/* compiled from: GuildScheduledEventListViewModel.kt */
public static final class StoreState {
private final boolean canCreateEvents;
private final Map<Long, Channel> guildChannels;
private final List<GuildScheduledEvent> guildScheduledEvents;
private final Set<Long> userGuildScheduledEventIds;
public StoreState(List<GuildScheduledEvent> list, Set<Long> set, Map<Long, Channel> map, boolean z2) {
m.checkNotNullParameter(list, "guildScheduledEvents");
m.checkNotNullParameter(set, "userGuildScheduledEventIds");
m.checkNotNullParameter(map, "guildChannels");
this.guildScheduledEvents = list;
this.userGuildScheduledEventIds = set;
this.guildChannels = map;
this.canCreateEvents = z2;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, 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, Set set, Map map, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
list = storeState.guildScheduledEvents;
}
if ((i & 2) != 0) {
set = storeState.userGuildScheduledEventIds;
}
if ((i & 4) != 0) {
map = storeState.guildChannels;
}
if ((i & 8) != 0) {
z2 = storeState.canCreateEvents;
}
return storeState.copy(list, set, map, z2);
}
public final List<GuildScheduledEvent> component1() {
return this.guildScheduledEvents;
}
public final Set<Long> component2() {
return this.userGuildScheduledEventIds;
}
public final Map<Long, Channel> component3() {
return this.guildChannels;
}
public final boolean component4() {
return this.canCreateEvents;
}
public final StoreState copy(List<GuildScheduledEvent> list, Set<Long> set, Map<Long, Channel> map, boolean z2) {
m.checkNotNullParameter(list, "guildScheduledEvents");
m.checkNotNullParameter(set, "userGuildScheduledEventIds");
m.checkNotNullParameter(map, "guildChannels");
return new StoreState(list, set, map, z2);
}
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.userGuildScheduledEventIds, storeState.userGuildScheduledEventIds) && m.areEqual(this.guildChannels, storeState.guildChannels) && this.canCreateEvents == storeState.canCreateEvents;
}
public final boolean getCanCreateEvents() {
return this.canCreateEvents;
}
public final Map<Long, Channel> getGuildChannels() {
return this.guildChannels;
}
public final List<GuildScheduledEvent> getGuildScheduledEvents() {
return this.guildScheduledEvents;
}
public final Set<Long> getUserGuildScheduledEventIds() {
return this.userGuildScheduledEventIds;
}
public int hashCode() {
List<GuildScheduledEvent> list = this.guildScheduledEvents;
int i = 0;
int hashCode = (list != null ? list.hashCode() : 0) * 31;
Set<Long> set = this.userGuildScheduledEventIds;
int hashCode2 = (hashCode + (set != null ? set.hashCode() : 0)) * 31;
Map<Long, Channel> map = this.guildChannels;
if (map != null) {
i = map.hashCode();
}
int i2 = (hashCode2 + i) * 31;
boolean z2 = this.canCreateEvents;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
return i2 + i3;
}
public String toString() {
StringBuilder P = a.P("StoreState(guildScheduledEvents=");
P.append(this.guildScheduledEvents);
P.append(", userGuildScheduledEventIds=");
P.append(this.userGuildScheduledEventIds);
P.append(", guildChannels=");
P.append(this.guildChannels);
P.append(", canCreateEvents=");
return a.L(P, this.canCreateEvents, ")");
}
}
/* 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 P = a.P("Loaded(guildScheduledEvents=");
P.append(this.guildScheduledEvents);
P.append(", canCreateEvents=");
return a.L(P, 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, Long l, 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.channelId = l;
this.guildScheduledEventsStore = storeGuildScheduledEvents;
this.channelsStore = storeChannels;
this.permissionsStore = storePermissions;
this.guildsStore = storeGuilds;
storeGuildScheduledEvents.fetchGuildScheduledEventUserCounts(j);
storeGuildScheduledEvents.fetchUserGuildScheduledEvents(j);
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, Long l, StoreGuildScheduledEvents storeGuildScheduledEvents, StoreChannels storeChannels, StorePermissions storePermissions, StoreGuilds storeGuilds, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(j, l, r0, r9, r10, r11, (i & 64) != 0 ? Companion.access$observeStores(Companion, j, l, r0, r9, r10, r11) : observable);
StoreGuildScheduledEvents guildScheduledEvents = (i & 4) != 0 ? StoreStream.Companion.getGuildScheduledEvents() : storeGuildScheduledEvents;
StoreChannels channels = (i & 8) != 0 ? StoreStream.Companion.getChannels() : storeChannels;
StorePermissions permissions = (i & 16) != 0 ? StoreStream.Companion.getPermissions() : storePermissions;
StoreGuilds guilds = (i & 32) != 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) {
Long b = guildScheduledEvent.b();
Long l = null;
Channel channel = b != null ? storeState.getGuildChannels().get(Long.valueOf(b.longValue())) : null;
boolean contains = storeState.getUserGuildScheduledEventIds().contains(Long.valueOf(guildScheduledEvent.g()));
GuildScheduledEventUtilities.Companion companion = GuildScheduledEventUtilities.Companion;
boolean canStartEvent$default = GuildScheduledEventUtilities.Companion.canStartEvent$default(companion, channel != null ? Long.valueOf(channel.h()) : null, null, null, 6, null);
if (channel != null) {
l = Long.valueOf(channel.h());
}
arrayList.add(new GuildScheduledEventListItem.Event(guildScheduledEvent, channel, contains, canStartEvent$default, GuildScheduledEventUtilities.Companion.canShareEvent$default(companion, l, null, null, null, 14, null)));
}
updateViewState(new ViewState.Loaded(arrayList, storeState.getCanCreateEvents()));
}
public final void toggleRsvp(GuildScheduledEvent guildScheduledEvent) {
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
this.guildScheduledEventsStore.toggleRsvpGuildScheduledEvent(guildScheduledEvent);
}
}