fix: Don't use emptyFlow

This commit is contained in:
Ahmad Ansori Palembani 2024-12-01 09:27:45 +07:00
parent b716275b6a
commit 4a5e5f60d7
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -56,7 +56,6 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
@ -231,33 +230,28 @@ class LibraryPresenter(
categories = lastCategories ?: getCategories.await().toMutableList()
}
combine(
getLibraryFlow(),
emptyFlow<Unit>(), // Placeholder flow for later usage
) { data, _ ->
getLibraryFlow().collectLatest { data ->
categories = data.categories
allCategories = data.allCategories
data.items
val library = data.items
val hiddenItems = library.filter { it.manga.isHidden() }.mapNotNull { it.manga.items }.flatten()
setDownloadCount(library)
setUnreadBadge(library)
setSourceLanguage(library)
setDownloadCount(hiddenItems)
setUnreadBadge(hiddenItems)
setSourceLanguage(hiddenItems)
allLibraryItems = library
hiddenLibraryItems = hiddenItems
val mangaMap = library
.applyFilters()
.applySort()
val freshStart = libraryItems.isEmpty()
sectionLibrary(mangaMap, freshStart)
}
.collectLatest { library ->
val hiddenItems = library.filter { it.manga.isHidden() }.mapNotNull { it.manga.items }.flatten()
setDownloadCount(library)
setUnreadBadge(library)
setSourceLanguage(library)
setDownloadCount(hiddenItems)
setUnreadBadge(hiddenItems)
setSourceLanguage(hiddenItems)
allLibraryItems = library
hiddenLibraryItems = hiddenItems
val mangaMap = library
.applyFilters()
.applySort()
val freshStart = libraryItems.isEmpty()
sectionLibrary(mangaMap, freshStart)
}
}
}