373 lines
14 KiB
Java
373 lines
14 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.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StorePermissions;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.threads.ThreadUtils;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetThreadBrowserViewModel.kt */
|
|
public final class WidgetThreadBrowserViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final long channelId;
|
|
private final long guildId;
|
|
private final StoreChannels storeChannels;
|
|
private final StoreGuilds storeGuilds;
|
|
private final StorePermissions storePermissions;
|
|
|
|
/* compiled from: WidgetThreadBrowserViewModel.kt */
|
|
/* renamed from: com.discord.widgets.channels.threads.browser.WidgetThreadBrowserViewModel$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
public final /* synthetic */ WidgetThreadBrowserViewModel this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(WidgetThreadBrowserViewModel widgetThreadBrowserViewModel) {
|
|
super(1);
|
|
this.this$0 = widgetThreadBrowserViewModel;
|
|
}
|
|
|
|
/* 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");
|
|
WidgetThreadBrowserViewModel.access$handleStoreState(this.this$0, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, long j, long j2, StoreChannels storeChannels, StoreGuilds storeGuilds, StorePermissions storePermissions) {
|
|
return companion.observeStoreState(j, j2, storeChannels, storeGuilds, storePermissions);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStoreState(long j, long j2, StoreChannels storeChannels, StoreGuilds storeGuilds, StorePermissions storePermissions) {
|
|
Observable<StoreState> i = Observable.i(storeChannels.observeChannel(j), storeGuilds.observeGuild(j2), storePermissions.observePermissionsForChannel(j), WidgetThreadBrowserViewModel$Companion$observeStoreState$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(i, "Observable.combineLatest…issions\n )\n }");
|
|
return i;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserViewModel.kt */
|
|
public static final class StoreState {
|
|
private final Channel channel;
|
|
private final Guild guild;
|
|
private final Long permissions;
|
|
|
|
public StoreState(Channel channel, Guild guild, Long l) {
|
|
this.channel = channel;
|
|
this.guild = guild;
|
|
this.permissions = l;
|
|
}
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, Channel channel, Guild guild, Long l, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
channel = storeState.channel;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
guild = storeState.guild;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
l = storeState.permissions;
|
|
}
|
|
return storeState.copy(channel, guild, l);
|
|
}
|
|
|
|
public final Channel component1() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final Guild component2() {
|
|
return this.guild;
|
|
}
|
|
|
|
public final Long component3() {
|
|
return this.permissions;
|
|
}
|
|
|
|
public final StoreState copy(Channel channel, Guild guild, Long l) {
|
|
return new StoreState(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.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 Long getPermissions() {
|
|
return this.permissions;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Channel channel = this.channel;
|
|
int i = 0;
|
|
int hashCode = (channel != null ? channel.hashCode() : 0) * 31;
|
|
Guild guild = this.guild;
|
|
int hashCode2 = (hashCode + (guild != null ? guild.hashCode() : 0)) * 31;
|
|
Long l = this.permissions;
|
|
if (l != null) {
|
|
i = l.hashCode();
|
|
}
|
|
return hashCode2 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("StoreState(channel=");
|
|
K.append(this.channel);
|
|
K.append(", guild=");
|
|
K.append(this.guild);
|
|
K.append(", permissions=");
|
|
return a.A(K, this.permissions, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: WidgetThreadBrowserViewModel.kt */
|
|
public static final class Browser extends ViewState {
|
|
private final boolean canCreateThread;
|
|
private final boolean canViewArchivedThreads;
|
|
private final String channelName;
|
|
|
|
public Browser(String str, boolean z2, boolean z3) {
|
|
super(null);
|
|
this.channelName = str;
|
|
this.canCreateThread = z2;
|
|
this.canViewArchivedThreads = z3;
|
|
}
|
|
|
|
public static /* synthetic */ Browser copy$default(Browser browser, String str, boolean z2, boolean z3, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = browser.channelName;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z2 = browser.canCreateThread;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z3 = browser.canViewArchivedThreads;
|
|
}
|
|
return browser.copy(str, z2, z3);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.channelName;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.canCreateThread;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.canViewArchivedThreads;
|
|
}
|
|
|
|
public final Browser copy(String str, boolean z2, boolean z3) {
|
|
return new Browser(str, z2, z3);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Browser)) {
|
|
return false;
|
|
}
|
|
Browser browser = (Browser) obj;
|
|
return m.areEqual(this.channelName, browser.channelName) && this.canCreateThread == browser.canCreateThread && this.canViewArchivedThreads == browser.canViewArchivedThreads;
|
|
}
|
|
|
|
public final boolean getCanCreateThread() {
|
|
return this.canCreateThread;
|
|
}
|
|
|
|
public final boolean getCanViewArchivedThreads() {
|
|
return this.canViewArchivedThreads;
|
|
}
|
|
|
|
public final String getChannelName() {
|
|
return this.channelName;
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.channelName;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
boolean z2 = this.canCreateThread;
|
|
int i = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = (hashCode + i2) * 31;
|
|
boolean z3 = this.canViewArchivedThreads;
|
|
if (!z3) {
|
|
i = z3 ? 1 : 0;
|
|
}
|
|
return i5 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("Browser(channelName=");
|
|
K.append(this.channelName);
|
|
K.append(", canCreateThread=");
|
|
K.append(this.canCreateThread);
|
|
K.append(", canViewArchivedThreads=");
|
|
return a.F(K, this.canViewArchivedThreads, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetThreadBrowserViewModel.kt */
|
|
public static final class GoToChannel extends ViewState {
|
|
private final Channel channel;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public GoToChannel(Channel channel) {
|
|
super(null);
|
|
m.checkNotNullParameter(channel, "channel");
|
|
this.channel = channel;
|
|
}
|
|
|
|
public static /* synthetic */ GoToChannel copy$default(GoToChannel goToChannel, Channel channel, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
channel = goToChannel.channel;
|
|
}
|
|
return goToChannel.copy(channel);
|
|
}
|
|
|
|
public final Channel component1() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final GoToChannel copy(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
return new GoToChannel(channel);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof GoToChannel) && m.areEqual(this.channel, ((GoToChannel) obj).channel);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Channel channel = this.channel;
|
|
if (channel != null) {
|
|
return channel.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("GoToChannel(channel=");
|
|
K.append(this.channel);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
private ViewState() {
|
|
}
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetThreadBrowserViewModel(long j, long j2, StoreChannels storeChannels, StoreGuilds storeGuilds, StorePermissions storePermissions, Observable<StoreState> observable) {
|
|
super(null, 1, null);
|
|
m.checkNotNullParameter(storeChannels, "storeChannels");
|
|
m.checkNotNullParameter(storeGuilds, "storeGuilds");
|
|
m.checkNotNullParameter(storePermissions, "storePermissions");
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
this.guildId = j;
|
|
this.channelId = j2;
|
|
this.storeChannels = storeChannels;
|
|
this.storeGuilds = storeGuilds;
|
|
this.storePermissions = storePermissions;
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(observable, this, null, 2, null), WidgetThreadBrowserViewModel.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 */ WidgetThreadBrowserViewModel(long j, long j2, StoreChannels storeChannels, StoreGuilds storeGuilds, StorePermissions storePermissions, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, j2, r0, r9, r10, (i & 32) != 0 ? Companion.access$observeStoreState(Companion, j2, j, r0, r9, r10) : observable);
|
|
StoreChannels channels = (i & 4) != 0 ? StoreStream.Companion.getChannels() : storeChannels;
|
|
StoreGuilds guilds = (i & 8) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds;
|
|
StorePermissions permissions = (i & 16) != 0 ? StoreStream.Companion.getPermissions() : storePermissions;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(WidgetThreadBrowserViewModel widgetThreadBrowserViewModel, StoreState storeState) {
|
|
widgetThreadBrowserViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
@MainThread
|
|
private final void handleStoreState(StoreState storeState) {
|
|
if (!(getViewState() instanceof ViewState.GoToChannel)) {
|
|
Channel channel = storeState.getChannel();
|
|
String y0 = channel != null ? AnimatableValueParser.y0(channel) : null;
|
|
ThreadUtils threadUtils = ThreadUtils.INSTANCE;
|
|
updateViewState(new ViewState.Browser(y0, threadUtils.canCreateThread(storeState.getPermissions(), storeState.getChannel(), null, storeState.getGuild()), threadUtils.canViewAllPublicArchivedThreads(storeState.getChannel(), storeState.getPermissions())));
|
|
}
|
|
}
|
|
|
|
public final long getChannelId() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final long getGuildId() {
|
|
return this.guildId;
|
|
}
|
|
|
|
public final void openThread(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
updateViewState(new ViewState.GoToChannel(channel));
|
|
}
|
|
}
|