discord-jadx/app/src/main/java/com/discord/widgets/chat/input/ChatInputViewModel$sendMess...

162 lines
9.0 KiB
Java

package com.discord.widgets.chat.input;
import android.content.Context;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.R;
import com.discord.api.channel.Channel;
import com.discord.stores.StoreSlowMode;
import com.discord.stores.StoreStream;
import com.discord.utilities.channel.ChannelSelector;
import com.discord.utilities.error.Error;
import com.discord.utilities.rest.RestAPIAbortMessages;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2;
import com.discord.utilities.threads.ThreadUtils;
import com.discord.widgets.chat.input.ChatInputViewModel;
import d0.z.d.m;
import d0.z.d.o;
import j0.k.b;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function3;
import rx.Observable;
/* compiled from: ChatInputViewModel.kt */
public final class ChatInputViewModel$sendMessage$1 extends o implements Function3<Long, String, Function1<? super Channel, ? extends Unit>, Unit> {
public final /* synthetic */ Context $context;
public final /* synthetic */ ChatInputViewModel.ViewState.Loaded $loadedViewState;
public final /* synthetic */ ChatInputViewModel this$0;
/* compiled from: ChatInputViewModel.kt */
/* renamed from: com.discord.widgets.chat.input.ChatInputViewModel$sendMessage$1$1 reason: invalid class name */
public static final class AnonymousClass1<T, R> implements b<Channel, Observable<? extends Channel>> {
public final /* synthetic */ ChatInputViewModel$sendMessage$1 this$0;
public AnonymousClass1(ChatInputViewModel$sendMessage$1 chatInputViewModel$sendMessage$1) {
this.this$0 = chatInputViewModel$sendMessage$1;
}
public final Observable<? extends Channel> call(Channel channel) {
Observable<R> F = ChatInputViewModel.access$getStoreChannels$p(this.this$0.this$0).observeChannel(channel.h()).x(ObservableExtensionsKt$filterNull$1.INSTANCE).F(ObservableExtensionsKt$filterNull$2.INSTANCE);
m.checkNotNullExpressionValue(F, "filter { it != null }.map { it!! }");
return ObservableExtensionsKt.computationLatest(ObservableExtensionsKt.takeSingleUntilTimeout$default(F, 0, false, 3, null));
}
}
/* compiled from: ChatInputViewModel.kt */
/* renamed from: com.discord.widgets.chat.input.ChatInputViewModel$sendMessage$1$2 reason: invalid class name */
public static final class AnonymousClass2 extends o implements Function1<Channel, Unit> {
public final /* synthetic */ Function1 $onThreadCreated;
public final /* synthetic */ ChatInputViewModel$sendMessage$1 this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass2(ChatInputViewModel$sendMessage$1 chatInputViewModel$sendMessage$1, Function1 function1) {
super(1);
this.this$0 = chatInputViewModel$sendMessage$1;
this.$onThreadCreated = function1;
}
/* 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) {
if (channel != null) {
StoreStream.Companion.getSlowMode().onThreadCreated(this.this$0.$loadedViewState.getChannelId());
Function1 function1 = this.$onThreadCreated;
if (function1 != null) {
function1.invoke(channel);
}
ChannelSelector.selectChannel$default(ChannelSelector.Companion.getInstance(), channel, null, null, 6, null);
}
}
}
/* compiled from: ChatInputViewModel.kt */
/* renamed from: com.discord.widgets.chat.input.ChatInputViewModel$sendMessage$1$3 reason: invalid class name */
public static final class AnonymousClass3 extends o implements Function1<Error, Unit> {
public final /* synthetic */ ChatInputViewModel$sendMessage$1 this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass3(ChatInputViewModel$sendMessage$1 chatInputViewModel$sendMessage$1) {
super(1);
this.this$0 = chatInputViewModel$sendMessage$1;
}
/* 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(Error error) {
invoke(error);
return Unit.a;
}
public final void invoke(Error error) {
m.checkNotNullParameter(error, "error");
Error.Response response = error.getResponse();
m.checkNotNullExpressionValue(response, "error.response");
Integer abortCodeMessageResId = RestAPIAbortMessages.getAbortCodeMessageResId(response.getCode());
Error.Response response2 = error.getResponse();
m.checkNotNullExpressionValue(response2, "error.response");
if (response2.getCode() == 20016) {
Error.Response response3 = error.getResponse();
m.checkNotNullExpressionValue(response3, "error.response");
Long retryAfterMs = response3.getRetryAfterMs();
if (retryAfterMs == null) {
retryAfterMs = 0L;
}
m.checkNotNullExpressionValue(retryAfterMs, "error.response.retryAfterMs ?: 0");
StoreStream.Companion.getSlowMode().onCooldown(this.this$0.$loadedViewState.getChannelId(), retryAfterMs.longValue(), StoreSlowMode.Type.ThreadCreate.INSTANCE);
}
c.a.d.m.g(this.this$0.$context, abortCodeMessageResId != null ? abortCodeMessageResId.intValue() : R.string.network_error_bad_request, 0, null, 12);
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ChatInputViewModel$sendMessage$1(ChatInputViewModel chatInputViewModel, ChatInputViewModel.ViewState.Loaded loaded, Context context) {
super(3);
this.this$0 = chatInputViewModel;
this.$loadedViewState = loaded;
this.$context = context;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.chat.input.ChatInputViewModel$sendMessage$1 */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ void invoke$default(ChatInputViewModel$sendMessage$1 chatInputViewModel$sendMessage$1, Long l, String str, Function1 function1, int i, Object obj) {
if ((i & 4) != 0) {
function1 = null;
}
chatInputViewModel$sendMessage$1.invoke(l, str, (Function1<? super Channel, Unit>) function1);
}
/* 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, java.lang.Object, java.lang.Object] */
@Override // kotlin.jvm.functions.Function3
public /* bridge */ /* synthetic */ Unit invoke(Long l, String str, Function1<? super Channel, ? extends Unit> function1) {
invoke(l, str, (Function1<? super Channel, Unit>) function1);
return Unit.a;
}
public final void invoke(Long l, String str, Function1<? super Channel, Unit> function1) {
ThreadUtils threadUtils = ThreadUtils.INSTANCE;
long channelId = this.$loadedViewState.getChannelId();
int i = AnimatableValueParser.d1(this.$loadedViewState.getChannel()) ? 10 : this.$loadedViewState.getThreadDraftState().isPrivate() ? 12 : 11;
String threadName = this.$loadedViewState.getThreadDraftState().getThreadName();
if (threadName == null) {
threadName = "";
}
Integer autoArchiveDuration = this.$loadedViewState.getThreadDraftState().getAutoArchiveDuration();
if (autoArchiveDuration == null) {
autoArchiveDuration = this.$loadedViewState.getChannel().d();
}
Observable z2 = ObservableExtensionsKt.restSubscribeOn$default(threadUtils.createThread(channelId, l, i, threadName, Integer.valueOf(autoArchiveDuration != null ? autoArchiveDuration.intValue() : 1440), str), false, 1, null).z(new AnonymousClass1(this));
m.checkNotNullExpressionValue(z2, "ThreadUtils.createThread…ationLatest()\n }");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(z2, this.this$0, null, 2, null), this.this$0.getClass(), (Context) null, (Function1) null, new AnonymousClass3(this), (Function0) null, (Function0) null, new AnonymousClass2(this, function1), 54, (Object) null);
}
}