From 032d4e8bb680e7e0ea2874a05b26392eb4e39c29 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Thu, 2 Feb 2023 23:48:29 -0500 Subject: [PATCH] Fix data listener only listening to new pages in updates --- .../jui/domain/updates/interactor/UpdatesPager.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/updates/interactor/UpdatesPager.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/updates/interactor/UpdatesPager.kt index c01a0164..c7ef76fa 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/updates/interactor/UpdatesPager.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/updates/interactor/UpdatesPager.kt @@ -75,10 +75,12 @@ class UpdatesPager @Inject constructor( } }.stateIn(this, SharingStarted.Eagerly, emptyList()) - private val mangaIds = fetchedUpdates.map { updates -> updates.map { it.manga.id } } - .stateIn(this, SharingStarted.Eagerly, emptyList()) - private val chapterIds = fetchedUpdates.map { updates -> updates.map { Triple(it.manga.id, it.chapter.index, it.chapter.id) } } - .stateIn(this, SharingStarted.Eagerly, emptyList()) + private val mangaIds = foldedUpdates.map { updates -> + updates.filterIsInstance().map { it.manga.id } + }.stateIn(this, SharingStarted.Eagerly, emptyList()) + private val chapterIds = foldedUpdates.map { updates -> + updates.filterIsInstance().map { Triple(it.manga.id, it.chapter.index, it.chapter.id) } + }.stateIn(this, SharingStarted.Eagerly, emptyList()) private val changedManga = serverListeners.mangaListener.runningFold(emptyMap()) { manga, updatedMangaIds -> coroutineScope {