package com.discord.stores; import android.content.Context; import com.discord.api.stageinstance.RecommendedStageInstance; import com.discord.stores.StoreRequestedStageChannels; import com.discord.utilities.error.Error; import com.discord.utilities.rx.ObservableExtensionsKt; import d0.t.u; import d0.z.d.m; import d0.z.d.o; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; /* compiled from: StoreRequestedStageChannels.kt */ public final class StoreRequestedStageChannels$fetchStageChannels$1 extends o implements Function0 { public final /* synthetic */ Set $channelIds; public final /* synthetic */ StoreRequestedStageChannels this$0; /* compiled from: StoreRequestedStageChannels.kt */ /* renamed from: com.discord.stores.StoreRequestedStageChannels$fetchStageChannels$1$1 reason: invalid class name */ public static final class AnonymousClass1 extends o implements Function1 { public final /* synthetic */ Set $channelIdsToRequest; public final /* synthetic */ StoreRequestedStageChannels$fetchStageChannels$1 this$0; /* compiled from: StoreRequestedStageChannels.kt */ /* renamed from: com.discord.stores.StoreRequestedStageChannels$fetchStageChannels$1$1$1 reason: invalid class name */ public static final class AnonymousClass1 extends o implements Function0 { public final /* synthetic */ AnonymousClass1 this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass1(AnonymousClass1 r1) { super(0); this.this$0 = r1; } @Override // kotlin.jvm.functions.Function0 /* renamed from: invoke */ public final void mo1invoke() { AnonymousClass1 r0 = this.this$0; StoreRequestedStageChannels.access$updateStatus(r0.this$0.this$0, r0.$channelIdsToRequest, StoreRequestedStageChannels.FetchStatus.ERROR); } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass1(StoreRequestedStageChannels$fetchStageChannels$1 storeRequestedStageChannels$fetchStageChannels$1, Set set) { super(1); this.this$0 = storeRequestedStageChannels$fetchStageChannels$1; this.$channelIdsToRequest = set; } /* 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, "it"); StoreRequestedStageChannels.access$getDispatcher$p(this.this$0.this$0).schedule(new AnonymousClass1(this)); } } /* compiled from: StoreRequestedStageChannels.kt */ /* renamed from: com.discord.stores.StoreRequestedStageChannels$fetchStageChannels$1$2 reason: invalid class name */ public static final class AnonymousClass2 extends o implements Function1, Unit> { public final /* synthetic */ Set $channelIdsToRequest; public final /* synthetic */ StoreRequestedStageChannels$fetchStageChannels$1 this$0; /* compiled from: StoreRequestedStageChannels.kt */ /* renamed from: com.discord.stores.StoreRequestedStageChannels$fetchStageChannels$1$2$1 reason: invalid class name */ public static final class AnonymousClass1 extends o implements Function0 { public final /* synthetic */ List $stageInstances; public final /* synthetic */ AnonymousClass2 this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass1(AnonymousClass2 r1, List list) { super(0); this.this$0 = r1; this.$stageInstances = list; } @Override // kotlin.jvm.functions.Function0 /* renamed from: invoke */ public final void mo1invoke() { AnonymousClass2 r0 = this.this$0; StoreRequestedStageChannels.access$onLoaded(r0.this$0.this$0, r0.$channelIdsToRequest, this.$stageInstances); } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass2(StoreRequestedStageChannels$fetchStageChannels$1 storeRequestedStageChannels$fetchStageChannels$1, Set set) { super(1); this.this$0 = storeRequestedStageChannels$fetchStageChannels$1; this.$channelIdsToRequest = set; } /* 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(List list) { invoke((List) list); return Unit.a; } public final void invoke(List list) { m.checkNotNullParameter(list, "stageInstances"); StoreRequestedStageChannels.access$getDispatcher$p(this.this$0.this$0).schedule(new AnonymousClass1(this, list)); } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public StoreRequestedStageChannels$fetchStageChannels$1(StoreRequestedStageChannels storeRequestedStageChannels, Set set) { super(0); this.this$0 = storeRequestedStageChannels; this.$channelIds = set; } @Override // kotlin.jvm.functions.Function0 /* renamed from: invoke */ public final void mo1invoke() { Set set = this.$channelIds; ArrayList arrayList = new ArrayList(); Iterator it = set.iterator(); while (true) { boolean z2 = false; if (it.hasNext()) { Object next = it.next(); StoreRequestedStageChannels.StageInstanceState stageInstanceState = (StoreRequestedStageChannels.StageInstanceState) StoreRequestedStageChannels.access$getRequestedStageChannelsSnapshot$p(this.this$0).get(Long.valueOf(((Number) next).longValue())); if (stageInstanceState == null || !stageInstanceState.isLoading()) { z2 = true; } if (z2) { arrayList.add(next); } } else { Set set2 = u.toSet(arrayList); StoreRequestedStageChannels.access$updateStatus(this.this$0, set2, StoreRequestedStageChannels.FetchStatus.LOADING); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.restSubscribeOn$default(StoreRequestedStageChannels.access$getRestAPI$p(this.this$0).getStageInstancesForChannels(set2), false, 1, null), this.this$0.getClass(), (Context) null, (Function1) null, new AnonymousClass1(this, set2), (Function0) null, (Function0) null, new AnonymousClass2(this, set2), 54, (Object) null); return; } } } }