376 lines
18 KiB
Java
376 lines
18 KiB
Java
package com.discord.widgets.directories;
|
|
|
|
import android.content.Context;
|
|
import c.d.b.a.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.directory.DirectoryEntry;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.hubs.DirectoryEntryCategory;
|
|
import com.discord.stores.StoreChannelsSelected;
|
|
import com.discord.stores.StoreDirectories;
|
|
import com.discord.stores.StoreGuildSelected;
|
|
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.stores.utilities.Default;
|
|
import com.discord.stores.utilities.RestCallState;
|
|
import com.discord.stores.utilities.RestCallStateKt;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2;
|
|
import d0.g;
|
|
import d0.t.n0;
|
|
import d0.z.d.k;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import j0.k.b;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import kotlin.Lazy;
|
|
import kotlin.Pair;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetDirectoriesViewModel.kt */
|
|
public final class WidgetDirectoriesViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final StoreChannelsSelected channelsSelectedStore;
|
|
private final StoreDirectories directoriesStore;
|
|
private final RestAPI restAPI;
|
|
|
|
/* compiled from: WidgetDirectoriesViewModel.kt */
|
|
/* renamed from: com.discord.widgets.directories.WidgetDirectoriesViewModel$1 reason: invalid class name */
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<ViewState, Unit> {
|
|
public AnonymousClass1(WidgetDirectoriesViewModel widgetDirectoriesViewModel) {
|
|
super(1, widgetDirectoriesViewModel, WidgetDirectoriesViewModel.class, "updateViewState", "updateViewState(Ljava/lang/Object;)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(ViewState viewState) {
|
|
invoke(viewState);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(ViewState viewState) {
|
|
m.checkNotNullParameter(viewState, "p1");
|
|
WidgetDirectoriesViewModel.access$updateViewState((WidgetDirectoriesViewModel) this.receiver, viewState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetDirectoriesViewModel.kt */
|
|
/* renamed from: com.discord.widgets.directories.WidgetDirectoriesViewModel$2 reason: invalid class name */
|
|
public static final class AnonymousClass2<T, R> implements b<Channel, Boolean> {
|
|
public static final AnonymousClass2 INSTANCE = new AnonymousClass2();
|
|
|
|
public final Boolean call(Channel channel) {
|
|
boolean z2 = true;
|
|
if (channel == null || !AnimatableValueParser.i1(channel)) {
|
|
z2 = false;
|
|
}
|
|
return Boolean.valueOf(z2);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetDirectoriesViewModel.kt */
|
|
/* renamed from: com.discord.widgets.directories.WidgetDirectoriesViewModel$3 reason: invalid class name */
|
|
public static final class AnonymousClass3 extends o implements Function1<Channel, Unit> {
|
|
public final /* synthetic */ WidgetDirectoriesViewModel this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass3(WidgetDirectoriesViewModel widgetDirectoriesViewModel) {
|
|
super(1);
|
|
this.this$0 = widgetDirectoriesViewModel;
|
|
}
|
|
|
|
/* 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(Channel channel) {
|
|
invoke(channel);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(Channel channel) {
|
|
this.this$0.getDirectoriesStore().fetchDirectoriesForChannel(channel.h());
|
|
this.this$0.getDirectoriesStore().fetchEntryCountsForChannel(channel.h());
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetDirectoriesViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStores(Companion companion, ObservationDeck observationDeck, StoreGuilds storeGuilds, StoreGuildSelected storeGuildSelected, StoreChannelsSelected storeChannelsSelected, StoreDirectories storeDirectories, StorePermissions storePermissions) {
|
|
return companion.observeStores(observationDeck, storeGuilds, storeGuildSelected, storeChannelsSelected, storeDirectories, storePermissions);
|
|
}
|
|
|
|
private final Observable<ViewState> observeStores(ObservationDeck observationDeck, StoreGuilds storeGuilds, StoreGuildSelected storeGuildSelected, StoreChannelsSelected storeChannelsSelected, StoreDirectories storeDirectories, StorePermissions storePermissions) {
|
|
return ObservationDeck.connectRx$default(observationDeck, new ObservationDeck.UpdateSource[]{storeGuilds, storeGuildSelected, storeDirectories, storeChannelsSelected, storePermissions}, false, null, null, new WidgetDirectoriesViewModel$Companion$observeStores$1(storeChannelsSelected, storeGuildSelected, storeGuilds, storePermissions, storeDirectories), 14, null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetDirectoriesViewModel.kt */
|
|
public static final class ViewState {
|
|
private final Set<Long> adminGuildIds;
|
|
private final Lazy allDirectoryEntryData$delegate;
|
|
private final Long channelId;
|
|
private final RestCallState<List<DirectoryEntry>> directories;
|
|
private final Lazy directoryEntryData$delegate;
|
|
private final Guild guild;
|
|
private final Set<Long> joinedGuildIds;
|
|
private final Lazy mappedTabs$delegate;
|
|
private final RestCallState<Map<Integer, Integer>> tabs;
|
|
|
|
public ViewState() {
|
|
this(null, null, null, null, null, null, 63, null);
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r6v0, resolved type: com.discord.stores.utilities.RestCallState<? extends java.util.List<com.discord.api.directory.DirectoryEntry>> */
|
|
/* JADX DEBUG: Multi-variable search result rejected for r7v0, resolved type: com.discord.stores.utilities.RestCallState<? extends java.util.Map<java.lang.Integer, java.lang.Integer>> */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public ViewState(Guild guild, Long l, Set<Long> set, Set<Long> set2, RestCallState<? extends List<DirectoryEntry>> restCallState, RestCallState<? extends Map<Integer, Integer>> restCallState2) {
|
|
m.checkNotNullParameter(set, "joinedGuildIds");
|
|
m.checkNotNullParameter(set2, "adminGuildIds");
|
|
m.checkNotNullParameter(restCallState, "directories");
|
|
m.checkNotNullParameter(restCallState2, "tabs");
|
|
this.guild = guild;
|
|
this.channelId = l;
|
|
this.joinedGuildIds = set;
|
|
this.adminGuildIds = set2;
|
|
this.directories = restCallState;
|
|
this.tabs = restCallState2;
|
|
this.allDirectoryEntryData$delegate = g.lazy(new WidgetDirectoriesViewModel$ViewState$allDirectoryEntryData$2(this));
|
|
this.directoryEntryData$delegate = g.lazy(new WidgetDirectoriesViewModel$ViewState$directoryEntryData$2(this));
|
|
this.mappedTabs$delegate = g.lazy(new WidgetDirectoriesViewModel$ViewState$mappedTabs$2(this));
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ ViewState(Guild guild, Long l, Set set, Set set2, RestCallState restCallState, RestCallState restCallState2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this((i & 1) != 0 ? null : guild, (i & 2) == 0 ? l : null, (i & 4) != 0 ? n0.emptySet() : set, (i & 8) != 0 ? n0.emptySet() : set2, (i & 16) != 0 ? Default.INSTANCE : restCallState, (i & 32) != 0 ? Default.INSTANCE : restCallState2);
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: com.discord.widgets.directories.WidgetDirectoriesViewModel$ViewState */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ ViewState copy$default(ViewState viewState, Guild guild, Long l, Set set, Set set2, RestCallState restCallState, RestCallState restCallState2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guild = viewState.guild;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
l = viewState.channelId;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
set = viewState.joinedGuildIds;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
set2 = viewState.adminGuildIds;
|
|
}
|
|
if ((i & 16) != 0) {
|
|
restCallState = viewState.directories;
|
|
}
|
|
if ((i & 32) != 0) {
|
|
restCallState2 = viewState.tabs;
|
|
}
|
|
return viewState.copy(guild, l, set, set2, restCallState, restCallState2);
|
|
}
|
|
|
|
public final Guild component1() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Long component2() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final Set<Long> component3() {
|
|
return this.joinedGuildIds;
|
|
}
|
|
|
|
public final Set<Long> component4() {
|
|
return this.adminGuildIds;
|
|
}
|
|
|
|
public final RestCallState<List<DirectoryEntry>> component5() {
|
|
return this.directories;
|
|
}
|
|
|
|
public final RestCallState<Map<Integer, Integer>> component6() {
|
|
return this.tabs;
|
|
}
|
|
|
|
public final ViewState copy(Guild guild, Long l, Set<Long> set, Set<Long> set2, RestCallState<? extends List<DirectoryEntry>> restCallState, RestCallState<? extends Map<Integer, Integer>> restCallState2) {
|
|
m.checkNotNullParameter(set, "joinedGuildIds");
|
|
m.checkNotNullParameter(set2, "adminGuildIds");
|
|
m.checkNotNullParameter(restCallState, "directories");
|
|
m.checkNotNullParameter(restCallState2, "tabs");
|
|
return new ViewState(guild, l, set, set2, restCallState, restCallState2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ViewState)) {
|
|
return false;
|
|
}
|
|
ViewState viewState = (ViewState) obj;
|
|
return m.areEqual(this.guild, viewState.guild) && m.areEqual(this.channelId, viewState.channelId) && m.areEqual(this.joinedGuildIds, viewState.joinedGuildIds) && m.areEqual(this.adminGuildIds, viewState.adminGuildIds) && m.areEqual(this.directories, viewState.directories) && m.areEqual(this.tabs, viewState.tabs);
|
|
}
|
|
|
|
public final Set<Long> getAdminGuildIds() {
|
|
return this.adminGuildIds;
|
|
}
|
|
|
|
public final List<DirectoryEntryData> getAllDirectoryEntryData() {
|
|
return (List) this.allDirectoryEntryData$delegate.getValue();
|
|
}
|
|
|
|
public final Long getChannelId() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final RestCallState<List<DirectoryEntry>> getDirectories() {
|
|
return this.directories;
|
|
}
|
|
|
|
public final Map<DirectoryEntryCategory, List<DirectoryEntryData>> getDirectoryEntryData() {
|
|
return (Map) this.directoryEntryData$delegate.getValue();
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Set<Long> getJoinedGuildIds() {
|
|
return this.joinedGuildIds;
|
|
}
|
|
|
|
public final List<Pair<DirectoryEntryCategory, Integer>> getMappedTabs() {
|
|
return (List) this.mappedTabs$delegate.getValue();
|
|
}
|
|
|
|
public final RestCallState<Map<Integer, Integer>> getTabs() {
|
|
return this.tabs;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Guild guild = this.guild;
|
|
int i = 0;
|
|
int hashCode = (guild != null ? guild.hashCode() : 0) * 31;
|
|
Long l = this.channelId;
|
|
int hashCode2 = (hashCode + (l != null ? l.hashCode() : 0)) * 31;
|
|
Set<Long> set = this.joinedGuildIds;
|
|
int hashCode3 = (hashCode2 + (set != null ? set.hashCode() : 0)) * 31;
|
|
Set<Long> set2 = this.adminGuildIds;
|
|
int hashCode4 = (hashCode3 + (set2 != null ? set2.hashCode() : 0)) * 31;
|
|
RestCallState<List<DirectoryEntry>> restCallState = this.directories;
|
|
int hashCode5 = (hashCode4 + (restCallState != null ? restCallState.hashCode() : 0)) * 31;
|
|
RestCallState<Map<Integer, Integer>> restCallState2 = this.tabs;
|
|
if (restCallState2 != null) {
|
|
i = restCallState2.hashCode();
|
|
}
|
|
return hashCode5 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("ViewState(guild=");
|
|
L.append(this.guild);
|
|
L.append(", channelId=");
|
|
L.append(this.channelId);
|
|
L.append(", joinedGuildIds=");
|
|
L.append(this.joinedGuildIds);
|
|
L.append(", adminGuildIds=");
|
|
L.append(this.adminGuildIds);
|
|
L.append(", directories=");
|
|
L.append(this.directories);
|
|
L.append(", tabs=");
|
|
L.append(this.tabs);
|
|
L.append(")");
|
|
return L.toString();
|
|
}
|
|
}
|
|
|
|
public WidgetDirectoriesViewModel() {
|
|
this(null, null, null, null, 15, null);
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetDirectoriesViewModel(StoreDirectories storeDirectories, StoreChannelsSelected storeChannelsSelected, RestAPI restAPI, Observable<ViewState> observable) {
|
|
super(new ViewState(null, null, null, null, null, null, 63, null));
|
|
m.checkNotNullParameter(storeDirectories, "directoriesStore");
|
|
m.checkNotNullParameter(storeChannelsSelected, "channelsSelectedStore");
|
|
m.checkNotNullParameter(restAPI, "restAPI");
|
|
m.checkNotNullParameter(observable, "storeObservable");
|
|
this.directoriesStore = storeDirectories;
|
|
this.channelsSelectedStore = storeChannelsSelected;
|
|
this.restAPI = restAPI;
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), WidgetDirectoriesViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
Observable<Channel> r = storeChannelsSelected.observeSelectedChannel().r();
|
|
m.checkNotNullExpressionValue(r, "channelsSelectedStore\n … .distinctUntilChanged()");
|
|
Observable<R> F = r.x(ObservableExtensionsKt$filterNull$1.INSTANCE).F(ObservableExtensionsKt$filterNull$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "filter { it != null }.map { it!! }");
|
|
Observable x2 = F.x(AnonymousClass2.INSTANCE);
|
|
m.checkNotNullExpressionValue(x2, "channelsSelectedStore\n …?.isDirectory() == true }");
|
|
ObservableExtensionsKt.appSubscribe$default(x2, WidgetDirectoriesViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass3(this), 62, (Object) null);
|
|
}
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public /* synthetic */ WidgetDirectoriesViewModel(StoreDirectories storeDirectories, StoreChannelsSelected storeChannelsSelected, RestAPI restAPI, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(storeDirectories, storeChannelsSelected, restAPI, observable);
|
|
storeDirectories = (i & 1) != 0 ? StoreStream.Companion.getDirectories() : storeDirectories;
|
|
storeChannelsSelected = (i & 2) != 0 ? StoreStream.Companion.getChannelsSelected() : storeChannelsSelected;
|
|
restAPI = (i & 4) != 0 ? RestAPI.Companion.getApi() : restAPI;
|
|
if ((i & 8) != 0) {
|
|
Companion companion = Companion;
|
|
ObservationDeck observationDeck = ObservationDeckProvider.get();
|
|
StoreStream.Companion companion2 = StoreStream.Companion;
|
|
observable = Companion.access$observeStores(companion, observationDeck, companion2.getGuilds(), companion2.getGuildSelected(), companion2.getChannelsSelected(), companion2.getDirectories(), companion2.getPermissions());
|
|
}
|
|
}
|
|
|
|
public static final /* synthetic */ void access$updateViewState(WidgetDirectoriesViewModel widgetDirectoriesViewModel, ViewState viewState) {
|
|
widgetDirectoriesViewModel.updateViewState(viewState);
|
|
}
|
|
|
|
public final StoreChannelsSelected getChannelsSelectedStore() {
|
|
return this.channelsSelectedStore;
|
|
}
|
|
|
|
public final StoreDirectories getDirectoriesStore() {
|
|
return this.directoriesStore;
|
|
}
|
|
|
|
public final String getHubName() {
|
|
Guild guild;
|
|
ViewState viewState = getViewState();
|
|
String name = (viewState == null || (guild = viewState.getGuild()) == null) ? null : guild.getName();
|
|
return name != null ? name : "";
|
|
}
|
|
|
|
public final RestAPI getRestAPI() {
|
|
return this.restAPI;
|
|
}
|
|
|
|
public final void joinGuild(long j, long j2) {
|
|
RestCallStateKt.executeRequest(this.restAPI.joinGuild(j, false, null, Long.valueOf(j2)), WidgetDirectoriesViewModel$joinGuild$1.INSTANCE);
|
|
}
|
|
|
|
public final void removeGuild(long j, long j2) {
|
|
this.directoriesStore.removeServerFromDirectory(j2, j);
|
|
}
|
|
}
|