MangaPresenter: Incognito and downloaded only label related tweaks ()

When manga screen takes time to load incognito and downloaded only label doesn't show up. It's fixed in the pr.
This commit is contained in:
AntsyLich 2022-07-17 02:45:05 +06:00 committed by GitHub
parent 9ebeff04e6
commit b034f503f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -147,6 +147,17 @@ class MangaPresenter(
_state.update { if (it is MangaScreenState.Success) func(it) else it }
}
private var incognitoMode = false
set(value) {
updateSuccessState { it.copy(isIncognitoMode = value) }
field = value
}
private var downloadedOnlyMode = false
set(value) {
updateSuccessState { it.copy(isDownloadedOnlyMode = value) }
field = value
}
override fun onCreate(savedState: Bundle?) {
super.onCreate(savedState)
@ -174,6 +185,8 @@ class MangaPresenter(
isFromSource = isFromSource,
trackingAvailable = trackManager.hasLoggedServices(),
chapters = chapterItems,
isIncognitoMode = incognitoMode,
isDownloadedOnlyMode = downloadedOnlyMode
)
// Update state
@ -195,13 +208,13 @@ class MangaPresenter(
preferences.incognitoMode()
.asImmediateFlow { incognito ->
updateSuccessState { it.copy(isIncognitoMode = incognito) }
incognitoMode = incognito
}
.launchIn(presenterScope)
preferences.downloadedOnly()
.asImmediateFlow { downloadedOnly ->
updateSuccessState { it.copy(isDownloadedOnlyMode = downloadedOnly) }
downloadedOnlyMode = downloadedOnly
}
.launchIn(presenterScope)
}