revert(manga/details): Revert flow usage

The value refuses to change for some reason
This commit is contained in:
Ahmad Ansori Palembani 2024-08-21 19:40:27 +07:00
parent 399c532cd2
commit ba7baba449
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 7 additions and 12 deletions

View file

@ -11,6 +11,3 @@
--> -->
## Fixes ## Fixes
- Fixed custom cover set from reader didn't show up on manga details - Fixed custom cover set from reader didn't show up on manga details
## Other
- Initial migration to use Flow on MangaDetailsPresenter

View file

@ -75,8 +75,6 @@ import java.util.Locale
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -114,11 +112,10 @@ class MangaDetailsPresenter(
private val updateChapter: UpdateChapter by injectLazy() private val updateChapter: UpdateChapter by injectLazy()
private val updateManga: UpdateManga by injectLazy() private val updateManga: UpdateManga by injectLazy()
private val currentMangaInternal: MutableStateFlow<Manga?> = MutableStateFlow(null) // private val currentMangaInternal: MutableStateFlow<Manga?> = MutableStateFlow(null)
val currentManga get() = currentMangaInternal.asStateFlow() // val currentManga get() = currentMangaInternal.asStateFlow()
val manga: Manga lateinit var manga: Manga
get() = currentManga.value!!
private val customMangaManager: CustomMangaManager by injectLazy() private val customMangaManager: CustomMangaManager by injectLazy()
private val mangaShortcutManager: MangaShortcutManager by injectLazy() private val mangaShortcutManager: MangaShortcutManager by injectLazy()
@ -156,8 +153,8 @@ class MangaDetailsPresenter(
fun onFirstLoad() { fun onFirstLoad() {
val controller = view ?: return val controller = view ?: return
isLockedFromSearch = controller.shouldLockIfNeeded && SecureActivityDelegate.shouldBeLocked() isLockedFromSearch = controller.shouldLockIfNeeded && SecureActivityDelegate.shouldBeLocked()
if (currentManga.value == null) runBlocking { refreshMangaFromDb() } if (!::manga.isInitialized) runBlocking { refreshMangaFromDb() }
if (currentManga.value == null) return // if (currentManga.value == null) return
syncData() syncData()
downloadManager.addListener(this) downloadManager.addListener(this)
LibraryUpdateJob.updateFlow LibraryUpdateJob.updateFlow
@ -198,7 +195,8 @@ class MangaDetailsPresenter(
} }
fun setCurrentManga(manga: Manga?) { fun setCurrentManga(manga: Manga?) {
currentMangaInternal.value = manga // currentMangaInternal.update { manga }
this.manga = manga!!
} }
// TODO: Use flow to "sync" data instead // TODO: Use flow to "sync" data instead