699 lines
32 KiB
Java
699 lines
32 KiB
Java
package com.discord.widgets.channels.threads.browser;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.MainThread;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.user.User;
|
|
import com.discord.stores.ArchivedThreadsStore;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreGuildMemberRequester;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StorePermissions;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.threads.ThreadUtils;
|
|
import com.discord.widgets.channels.threads.browser.ThreadBrowserThreadView;
|
|
import com.discord.widgets.channels.threads.browser.WidgetThreadBrowserAdapter;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.ArrayList;
|
|
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.BehaviorSubject;
|
|
/* compiled from: WidgetThreadBrowserArchivedViewModel.kt */
|
|
public final class WidgetThreadBrowserArchivedViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private boolean canLoadMore;
|
|
private final long channelId;
|
|
private final long guildId;
|
|
private final ArchivedThreadsStore storeArchivedThreads;
|
|
private final StoreChannels storeChannels;
|
|
private final StoreGuildMemberRequester storeGuildMemberRequester;
|
|
private final StoreGuilds storeGuilds;
|
|
private final StorePermissions storePermissions;
|
|
private final Observable<StoreState> storeStateObservable;
|
|
private final StoreUser storeUser;
|
|
private final BehaviorSubject<ViewMode> viewModeSubject;
|
|
|
|
/* compiled from: WidgetThreadBrowserArchivedViewModel.kt */
|
|
/* renamed from: com.discord.widgets.channels.threads.browser.WidgetThreadBrowserArchivedViewModel$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
public final /* synthetic */ WidgetThreadBrowserArchivedViewModel this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel) {
|
|
super(1);
|
|
this.this$0 = widgetThreadBrowserArchivedViewModel;
|
|
}
|
|
|
|
/* 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, "storeState");
|
|
WidgetThreadBrowserArchivedViewModel.access$handleStoreState(this.this$0, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserArchivedViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, ViewMode viewMode, long j, long j2, StoreGuilds storeGuilds, StoreChannels storeChannels, StoreUser storeUser, ArchivedThreadsStore archivedThreadsStore, StorePermissions storePermissions) {
|
|
return companion.observeStoreState(viewMode, j, j2, storeGuilds, storeChannels, storeUser, archivedThreadsStore, storePermissions);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStoreState(ViewMode viewMode, long j, long j2, StoreGuilds storeGuilds, StoreChannels storeChannels, StoreUser storeUser, ArchivedThreadsStore archivedThreadsStore, StorePermissions storePermissions) {
|
|
Observable<StoreState> Y = Observable.j(archivedThreadsStore.loadAndObserveThreadListing(j2, viewMode.getThreadListingType()), storeChannels.observeChannel(j2), WidgetThreadBrowserArchivedViewModel$Companion$observeStoreState$1.INSTANCE).Y(new WidgetThreadBrowserArchivedViewModel$Companion$observeStoreState$2(storeUser, storeGuilds, j, storePermissions, viewMode));
|
|
m.checkNotNullExpressionValue(Y, "Observable.combineLatest… }\n }");
|
|
return Y;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserArchivedViewModel.kt */
|
|
public static final class StoreState {
|
|
private final Channel channel;
|
|
private final Guild guild;
|
|
private final Map<Long, GuildMember> guildMembers;
|
|
private final boolean isModerator;
|
|
private final ArchivedThreadsStore.ThreadListingState listingState;
|
|
private final Long permissions;
|
|
private final Map<Long, User> users;
|
|
private final ViewMode viewMode;
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: java.util.Map<java.lang.Long, ? extends com.discord.models.user.User> */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public StoreState(ViewMode viewMode, Map<Long, GuildMember> map, Map<Long, ? extends User> map2, ArchivedThreadsStore.ThreadListingState threadListingState, boolean z2, Channel channel, Guild guild, Long l) {
|
|
m.checkNotNullParameter(viewMode, "viewMode");
|
|
m.checkNotNullParameter(map, "guildMembers");
|
|
m.checkNotNullParameter(map2, "users");
|
|
m.checkNotNullParameter(threadListingState, "listingState");
|
|
m.checkNotNullParameter(channel, "channel");
|
|
this.viewMode = viewMode;
|
|
this.guildMembers = map;
|
|
this.users = map2;
|
|
this.listingState = threadListingState;
|
|
this.isModerator = z2;
|
|
this.channel = channel;
|
|
this.guild = guild;
|
|
this.permissions = l;
|
|
}
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, ViewMode viewMode, Map map, Map map2, ArchivedThreadsStore.ThreadListingState threadListingState, boolean z2, Channel channel, Guild guild, Long l, int i, Object obj) {
|
|
return storeState.copy((i & 1) != 0 ? storeState.viewMode : viewMode, (i & 2) != 0 ? storeState.guildMembers : map, (i & 4) != 0 ? storeState.users : map2, (i & 8) != 0 ? storeState.listingState : threadListingState, (i & 16) != 0 ? storeState.isModerator : z2, (i & 32) != 0 ? storeState.channel : channel, (i & 64) != 0 ? storeState.guild : guild, (i & 128) != 0 ? storeState.permissions : l);
|
|
}
|
|
|
|
public final ViewMode component1() {
|
|
return this.viewMode;
|
|
}
|
|
|
|
public final Map<Long, GuildMember> component2() {
|
|
return this.guildMembers;
|
|
}
|
|
|
|
public final Map<Long, User> component3() {
|
|
return this.users;
|
|
}
|
|
|
|
public final ArchivedThreadsStore.ThreadListingState component4() {
|
|
return this.listingState;
|
|
}
|
|
|
|
public final boolean component5() {
|
|
return this.isModerator;
|
|
}
|
|
|
|
public final Channel component6() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild component7() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Long component8() {
|
|
return this.permissions;
|
|
}
|
|
|
|
public final StoreState copy(ViewMode viewMode, Map<Long, GuildMember> map, Map<Long, ? extends User> map2, ArchivedThreadsStore.ThreadListingState threadListingState, boolean z2, Channel channel, Guild guild, Long l) {
|
|
m.checkNotNullParameter(viewMode, "viewMode");
|
|
m.checkNotNullParameter(map, "guildMembers");
|
|
m.checkNotNullParameter(map2, "users");
|
|
m.checkNotNullParameter(threadListingState, "listingState");
|
|
m.checkNotNullParameter(channel, "channel");
|
|
return new StoreState(viewMode, map, map2, threadListingState, z2, channel, guild, l);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StoreState)) {
|
|
return false;
|
|
}
|
|
StoreState storeState = (StoreState) obj;
|
|
return m.areEqual(this.viewMode, storeState.viewMode) && m.areEqual(this.guildMembers, storeState.guildMembers) && m.areEqual(this.users, storeState.users) && m.areEqual(this.listingState, storeState.listingState) && this.isModerator == storeState.isModerator && m.areEqual(this.channel, storeState.channel) && m.areEqual(this.guild, storeState.guild) && m.areEqual(this.permissions, storeState.permissions);
|
|
}
|
|
|
|
public final Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild getGuild() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Map<Long, GuildMember> getGuildMembers() {
|
|
return this.guildMembers;
|
|
}
|
|
|
|
public final ArchivedThreadsStore.ThreadListingState getListingState() {
|
|
return this.listingState;
|
|
}
|
|
|
|
public final Long getPermissions() {
|
|
return this.permissions;
|
|
}
|
|
|
|
public final Map<Long, User> getUsers() {
|
|
return this.users;
|
|
}
|
|
|
|
public final ViewMode getViewMode() {
|
|
return this.viewMode;
|
|
}
|
|
|
|
public int hashCode() {
|
|
ViewMode viewMode = this.viewMode;
|
|
int i = 0;
|
|
int hashCode = (viewMode != null ? viewMode.hashCode() : 0) * 31;
|
|
Map<Long, GuildMember> map = this.guildMembers;
|
|
int hashCode2 = (hashCode + (map != null ? map.hashCode() : 0)) * 31;
|
|
Map<Long, User> map2 = this.users;
|
|
int hashCode3 = (hashCode2 + (map2 != null ? map2.hashCode() : 0)) * 31;
|
|
ArchivedThreadsStore.ThreadListingState threadListingState = this.listingState;
|
|
int hashCode4 = (hashCode3 + (threadListingState != null ? threadListingState.hashCode() : 0)) * 31;
|
|
boolean z2 = this.isModerator;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = (hashCode4 + i2) * 31;
|
|
Channel channel = this.channel;
|
|
int hashCode5 = (i5 + (channel != null ? channel.hashCode() : 0)) * 31;
|
|
Guild guild = this.guild;
|
|
int hashCode6 = (hashCode5 + (guild != null ? guild.hashCode() : 0)) * 31;
|
|
Long l = this.permissions;
|
|
if (l != null) {
|
|
i = l.hashCode();
|
|
}
|
|
return hashCode6 + i;
|
|
}
|
|
|
|
public final boolean isModerator() {
|
|
return this.isModerator;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("StoreState(viewMode=");
|
|
K.append(this.viewMode);
|
|
K.append(", guildMembers=");
|
|
K.append(this.guildMembers);
|
|
K.append(", users=");
|
|
K.append(this.users);
|
|
K.append(", listingState=");
|
|
K.append(this.listingState);
|
|
K.append(", isModerator=");
|
|
K.append(this.isModerator);
|
|
K.append(", channel=");
|
|
K.append(this.channel);
|
|
K.append(", guild=");
|
|
K.append(this.guild);
|
|
K.append(", permissions=");
|
|
return a.A(K, this.permissions, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserArchivedViewModel.kt */
|
|
public static final class ViewMode {
|
|
private final boolean isModeratorMode;
|
|
private final ArchivedThreadsStore.ThreadListingType threadListingType;
|
|
private final VisibilityMode visibility;
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
VisibilityMode.values();
|
|
int[] iArr = new int[2];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[VisibilityMode.PublicThreads.ordinal()] = 1;
|
|
}
|
|
}
|
|
|
|
public ViewMode(VisibilityMode visibilityMode, boolean z2) {
|
|
ArchivedThreadsStore.ThreadListingType threadListingType;
|
|
m.checkNotNullParameter(visibilityMode, "visibility");
|
|
this.visibility = visibilityMode;
|
|
this.isModeratorMode = z2;
|
|
if (visibilityMode.ordinal() == 0) {
|
|
threadListingType = ArchivedThreadsStore.ThreadListingType.ALL_ARCHIVED_PUBLIC_THREADS;
|
|
} else if (!z2) {
|
|
threadListingType = ArchivedThreadsStore.ThreadListingType.MY_ARCHIVED_PRIVATE_THREADS;
|
|
} else if (z2) {
|
|
threadListingType = ArchivedThreadsStore.ThreadListingType.ALL_ARCHIVED_PRIVATE_THREADS;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
this.threadListingType = threadListingType;
|
|
}
|
|
|
|
public static /* synthetic */ ViewMode copy$default(ViewMode viewMode, VisibilityMode visibilityMode, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
visibilityMode = viewMode.visibility;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z2 = viewMode.isModeratorMode;
|
|
}
|
|
return viewMode.copy(visibilityMode, z2);
|
|
}
|
|
|
|
public final VisibilityMode component1() {
|
|
return this.visibility;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.isModeratorMode;
|
|
}
|
|
|
|
public final ViewMode copy(VisibilityMode visibilityMode, boolean z2) {
|
|
m.checkNotNullParameter(visibilityMode, "visibility");
|
|
return new ViewMode(visibilityMode, z2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ViewMode)) {
|
|
return false;
|
|
}
|
|
ViewMode viewMode = (ViewMode) obj;
|
|
return m.areEqual(this.visibility, viewMode.visibility) && this.isModeratorMode == viewMode.isModeratorMode;
|
|
}
|
|
|
|
public final ArchivedThreadsStore.ThreadListingType getThreadListingType() {
|
|
return this.threadListingType;
|
|
}
|
|
|
|
public final VisibilityMode getVisibility() {
|
|
return this.visibility;
|
|
}
|
|
|
|
public int hashCode() {
|
|
VisibilityMode visibilityMode = this.visibility;
|
|
int hashCode = (visibilityMode != null ? visibilityMode.hashCode() : 0) * 31;
|
|
boolean z2 = this.isModeratorMode;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i = z2 ? 1 : 0;
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
return hashCode + i;
|
|
}
|
|
|
|
public final boolean isModeratorMode() {
|
|
return this.isModeratorMode;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ViewMode(visibility=");
|
|
K.append(this.visibility);
|
|
K.append(", isModeratorMode=");
|
|
return a.F(K, this.isModeratorMode, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserArchivedViewModel.kt */
|
|
public static final class ViewState {
|
|
private final boolean canCreateThread;
|
|
private final boolean isError;
|
|
private final boolean isModerator;
|
|
private final List<WidgetThreadBrowserAdapter.Item> listItems;
|
|
private final ViewMode viewMode;
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: java.util.List<? extends com.discord.widgets.channels.threads.browser.WidgetThreadBrowserAdapter$Item> */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public ViewState(ViewMode viewMode, List<? extends WidgetThreadBrowserAdapter.Item> list, boolean z2, boolean z3, boolean z4) {
|
|
m.checkNotNullParameter(viewMode, "viewMode");
|
|
m.checkNotNullParameter(list, "listItems");
|
|
this.viewMode = viewMode;
|
|
this.listItems = list;
|
|
this.isModerator = z2;
|
|
this.isError = z3;
|
|
this.canCreateThread = z4;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: com.discord.widgets.channels.threads.browser.WidgetThreadBrowserArchivedViewModel$ViewState */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ ViewState copy$default(ViewState viewState, ViewMode viewMode, List list, boolean z2, boolean z3, boolean z4, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
viewMode = viewState.viewMode;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
list = viewState.listItems;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z2 = viewState.isModerator;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
z3 = viewState.isError;
|
|
}
|
|
if ((i & 16) != 0) {
|
|
z4 = viewState.canCreateThread;
|
|
}
|
|
return viewState.copy(viewMode, list, z2, z3, z4);
|
|
}
|
|
|
|
public final ViewMode component1() {
|
|
return this.viewMode;
|
|
}
|
|
|
|
public final List<WidgetThreadBrowserAdapter.Item> component2() {
|
|
return this.listItems;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.isModerator;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.isError;
|
|
}
|
|
|
|
public final boolean component5() {
|
|
return this.canCreateThread;
|
|
}
|
|
|
|
public final ViewState copy(ViewMode viewMode, List<? extends WidgetThreadBrowserAdapter.Item> list, boolean z2, boolean z3, boolean z4) {
|
|
m.checkNotNullParameter(viewMode, "viewMode");
|
|
m.checkNotNullParameter(list, "listItems");
|
|
return new ViewState(viewMode, list, z2, z3, z4);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ViewState)) {
|
|
return false;
|
|
}
|
|
ViewState viewState = (ViewState) obj;
|
|
return m.areEqual(this.viewMode, viewState.viewMode) && m.areEqual(this.listItems, viewState.listItems) && this.isModerator == viewState.isModerator && this.isError == viewState.isError && this.canCreateThread == viewState.canCreateThread;
|
|
}
|
|
|
|
public final boolean getCanCreateThread() {
|
|
return this.canCreateThread;
|
|
}
|
|
|
|
public final List<WidgetThreadBrowserAdapter.Item> getListItems() {
|
|
return this.listItems;
|
|
}
|
|
|
|
public final ViewMode getViewMode() {
|
|
return this.viewMode;
|
|
}
|
|
|
|
public int hashCode() {
|
|
ViewMode viewMode = this.viewMode;
|
|
int i = 0;
|
|
int hashCode = (viewMode != null ? viewMode.hashCode() : 0) * 31;
|
|
List<WidgetThreadBrowserAdapter.Item> list = this.listItems;
|
|
if (list != null) {
|
|
i = list.hashCode();
|
|
}
|
|
int i2 = (hashCode + i) * 31;
|
|
boolean z2 = this.isModerator;
|
|
int i3 = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
int i6 = z2 ? 1 : 0;
|
|
int i7 = (i2 + i4) * 31;
|
|
boolean z3 = this.isError;
|
|
if (z3) {
|
|
z3 = true;
|
|
}
|
|
int i8 = z3 ? 1 : 0;
|
|
int i9 = z3 ? 1 : 0;
|
|
int i10 = z3 ? 1 : 0;
|
|
int i11 = (i7 + i8) * 31;
|
|
boolean z4 = this.canCreateThread;
|
|
if (!z4) {
|
|
i3 = z4 ? 1 : 0;
|
|
}
|
|
return i11 + i3;
|
|
}
|
|
|
|
public final boolean isError() {
|
|
return this.isError;
|
|
}
|
|
|
|
public final boolean isModerator() {
|
|
return this.isModerator;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ViewState(viewMode=");
|
|
K.append(this.viewMode);
|
|
K.append(", listItems=");
|
|
K.append(this.listItems);
|
|
K.append(", isModerator=");
|
|
K.append(this.isModerator);
|
|
K.append(", isError=");
|
|
K.append(this.isError);
|
|
K.append(", canCreateThread=");
|
|
return a.F(K, this.canCreateThread, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserArchivedViewModel.kt */
|
|
public enum VisibilityMode {
|
|
PublicThreads,
|
|
PrivateThreads
|
|
}
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
|
|
|
|
static {
|
|
VisibilityMode.values();
|
|
int[] iArr = new int[2];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[VisibilityMode.PublicThreads.ordinal()] = 1;
|
|
iArr[VisibilityMode.PrivateThreads.ordinal()] = 2;
|
|
ArchivedThreadsStore.ThreadListingType.values();
|
|
int[] iArr2 = new int[3];
|
|
$EnumSwitchMapping$1 = iArr2;
|
|
iArr2[ArchivedThreadsStore.ThreadListingType.ALL_ARCHIVED_PUBLIC_THREADS.ordinal()] = 1;
|
|
iArr2[ArchivedThreadsStore.ThreadListingType.MY_ARCHIVED_PRIVATE_THREADS.ordinal()] = 2;
|
|
iArr2[ArchivedThreadsStore.ThreadListingType.ALL_ARCHIVED_PRIVATE_THREADS.ordinal()] = 3;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetThreadBrowserArchivedViewModel(long j, long j2, StoreGuilds storeGuilds, StoreChannels storeChannels, StoreUser storeUser, ArchivedThreadsStore archivedThreadsStore, StorePermissions storePermissions, StoreGuildMemberRequester storeGuildMemberRequester) {
|
|
super(null, 1, null);
|
|
m.checkNotNullParameter(storeGuilds, "storeGuilds");
|
|
m.checkNotNullParameter(storeChannels, "storeChannels");
|
|
m.checkNotNullParameter(storeUser, "storeUser");
|
|
m.checkNotNullParameter(archivedThreadsStore, "storeArchivedThreads");
|
|
m.checkNotNullParameter(storePermissions, "storePermissions");
|
|
m.checkNotNullParameter(storeGuildMemberRequester, "storeGuildMemberRequester");
|
|
this.guildId = j;
|
|
this.channelId = j2;
|
|
this.storeGuilds = storeGuilds;
|
|
this.storeChannels = storeChannels;
|
|
this.storeUser = storeUser;
|
|
this.storeArchivedThreads = archivedThreadsStore;
|
|
this.storePermissions = storePermissions;
|
|
this.storeGuildMemberRequester = storeGuildMemberRequester;
|
|
BehaviorSubject<ViewMode> l0 = BehaviorSubject.l0(new ViewMode(VisibilityMode.PublicThreads, false));
|
|
m.checkNotNullExpressionValue(l0, "BehaviorSubject.create(\n…rMode = false\n )\n )");
|
|
this.viewModeSubject = l0;
|
|
Observable<R> Y = l0.Y(new WidgetThreadBrowserArchivedViewModel$storeStateObservable$1(this));
|
|
m.checkNotNullExpressionValue(Y, "viewModeSubject\n … )\n }");
|
|
this.storeStateObservable = Y;
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(Y, this, null, 2, null), WidgetThreadBrowserArchivedViewModel.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 */ WidgetThreadBrowserArchivedViewModel(long j, long j2, StoreGuilds storeGuilds, StoreChannels storeChannels, StoreUser storeUser, ArchivedThreadsStore archivedThreadsStore, StorePermissions storePermissions, StoreGuildMemberRequester storeGuildMemberRequester, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, j2, (i & 4) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds, (i & 8) != 0 ? StoreStream.Companion.getChannels() : storeChannels, (i & 16) != 0 ? StoreStream.Companion.getUsers() : storeUser, (i & 32) != 0 ? StoreStream.Companion.getArchivedThreads() : archivedThreadsStore, (i & 64) != 0 ? StoreStream.Companion.getPermissions() : storePermissions, (i & 128) != 0 ? StoreStream.Companion.getGuildMemberRequester() : storeGuildMemberRequester);
|
|
}
|
|
|
|
public static final /* synthetic */ long access$getChannelId$p(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel) {
|
|
return widgetThreadBrowserArchivedViewModel.channelId;
|
|
}
|
|
|
|
public static final /* synthetic */ long access$getGuildId$p(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel) {
|
|
return widgetThreadBrowserArchivedViewModel.guildId;
|
|
}
|
|
|
|
public static final /* synthetic */ ArchivedThreadsStore access$getStoreArchivedThreads$p(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel) {
|
|
return widgetThreadBrowserArchivedViewModel.storeArchivedThreads;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreChannels access$getStoreChannels$p(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel) {
|
|
return widgetThreadBrowserArchivedViewModel.storeChannels;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreGuilds access$getStoreGuilds$p(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel) {
|
|
return widgetThreadBrowserArchivedViewModel.storeGuilds;
|
|
}
|
|
|
|
public static final /* synthetic */ StorePermissions access$getStorePermissions$p(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel) {
|
|
return widgetThreadBrowserArchivedViewModel.storePermissions;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreUser access$getStoreUser$p(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel) {
|
|
return widgetThreadBrowserArchivedViewModel.storeUser;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel, StoreState storeState) {
|
|
widgetThreadBrowserArchivedViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
@MainThread
|
|
private final void handleStoreState(StoreState storeState) {
|
|
boolean z2;
|
|
int i;
|
|
ThreadBrowserThreadView.TimestampMode timestampMode;
|
|
ViewMode viewMode = storeState.getViewMode();
|
|
ArrayList arrayList = new ArrayList();
|
|
boolean isModerator = storeState.isModerator();
|
|
ArchivedThreadsStore.ThreadListingState listingState = storeState.getListingState();
|
|
boolean z3 = true;
|
|
if (listingState instanceof ArchivedThreadsStore.ThreadListingState.Listing) {
|
|
ArchivedThreadsStore.ThreadListingState.Listing listing = (ArchivedThreadsStore.ThreadListingState.Listing) listingState;
|
|
if (!listing.getThreads().isEmpty()) {
|
|
int ordinal = viewMode.getVisibility().ordinal();
|
|
if (ordinal == 0) {
|
|
i = 2131894086;
|
|
} else if (ordinal == 1) {
|
|
i = 2131894084;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
arrayList.add(new WidgetThreadBrowserAdapter.Item.Header("header", i, listing.getThreads().size()));
|
|
for (Channel channel : listing.getThreads()) {
|
|
User user = storeState.getUsers().get(Long.valueOf(channel.q()));
|
|
if (user == null || !storeState.getGuildMembers().containsKey(Long.valueOf(channel.q()))) {
|
|
this.storeGuildMemberRequester.queueRequest(channel.f(), channel.q());
|
|
}
|
|
Map<Long, GuildMember> guildMembers = storeState.getGuildMembers();
|
|
boolean z4 = viewMode.getThreadListingType() == ArchivedThreadsStore.ThreadListingType.MY_ARCHIVED_PRIVATE_THREADS;
|
|
if (z4) {
|
|
timestampMode = ThreadBrowserThreadView.TimestampMode.CreatedAt;
|
|
} else if (!z4) {
|
|
timestampMode = ThreadBrowserThreadView.TimestampMode.ArchivedAt;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
arrayList.add(new WidgetThreadBrowserAdapter.Item.Thread(new ThreadBrowserThreadView.ThreadData.ArchivedThread(channel, guildMembers, user, timestampMode)));
|
|
}
|
|
}
|
|
if (listing.isLoadingMore()) {
|
|
arrayList.add(new WidgetThreadBrowserAdapter.Item.Loading(null, 1, null));
|
|
}
|
|
if (listing.isLoadingMore() || !listing.getHasMore()) {
|
|
z3 = false;
|
|
}
|
|
this.canLoadMore = z3;
|
|
} else if (listingState instanceof ArchivedThreadsStore.ThreadListingState.Uninitialized) {
|
|
arrayList.add(new WidgetThreadBrowserAdapter.Item.Loading(null, 1, null));
|
|
} else if (listingState instanceof ArchivedThreadsStore.ThreadListingState.Error) {
|
|
z2 = true;
|
|
this.storeGuildMemberRequester.performQueuedRequests();
|
|
updateViewState(new ViewState(viewMode, arrayList, isModerator, z2, ThreadUtils.INSTANCE.canCreateThread(storeState.getPermissions(), storeState.getChannel(), null, storeState.getGuild())));
|
|
}
|
|
z2 = false;
|
|
this.storeGuildMemberRequester.performQueuedRequests();
|
|
updateViewState(new ViewState(viewMode, arrayList, isModerator, z2, ThreadUtils.INSTANCE.canCreateThread(storeState.getPermissions(), storeState.getChannel(), null, storeState.getGuild())));
|
|
}
|
|
|
|
public static /* synthetic */ void maybeLoadMore$default(WidgetThreadBrowserArchivedViewModel widgetThreadBrowserArchivedViewModel, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
z2 = false;
|
|
}
|
|
widgetThreadBrowserArchivedViewModel.maybeLoadMore(z2);
|
|
}
|
|
|
|
@MainThread
|
|
public final void maybeLoadMore(boolean z2) {
|
|
if (this.canLoadMore || z2) {
|
|
ArchivedThreadsStore.fetchListing$default(this.storeArchivedThreads, this.channelId, this.viewModeSubject.n0().getThreadListingType(), false, 4, null);
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void onModeratorModeChanged(boolean z2) {
|
|
BehaviorSubject<ViewMode> behaviorSubject = this.viewModeSubject;
|
|
behaviorSubject.onNext(ViewMode.copy$default(behaviorSubject.n0(), null, z2, 1, null));
|
|
trackTabChanged();
|
|
}
|
|
|
|
@MainThread
|
|
public final void onVisibilityChanged(VisibilityMode visibilityMode) {
|
|
m.checkNotNullParameter(visibilityMode, "visibility");
|
|
BehaviorSubject<ViewMode> behaviorSubject = this.viewModeSubject;
|
|
behaviorSubject.onNext(ViewMode.copy$default(behaviorSubject.n0(), visibilityMode, false, 2, null));
|
|
trackTabChanged();
|
|
}
|
|
|
|
public final void trackTabChanged() {
|
|
String str;
|
|
ViewMode n0 = this.viewModeSubject.n0();
|
|
if (n0 != null) {
|
|
int ordinal = n0.getThreadListingType().ordinal();
|
|
if (ordinal == 0) {
|
|
str = "My Private Archived Threads";
|
|
} else if (ordinal == 1) {
|
|
str = "Public Archived Threads";
|
|
} else if (ordinal == 2) {
|
|
str = "All Private Archived Threads";
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
StoreStream.Companion.getAnalytics().trackThreadBrowserTabChanged(this.channelId, str);
|
|
}
|
|
}
|
|
}
|