Cleanup FavouriteStatusRouter stateFlow
This commit is contained in:
1 parent
77502e1a7c
commit
78aab4f6c7
2 files changed
+3
-5
No files matched your search
@@ -23,8 +23,8 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.shareIn
|
||||
import kotlinx.coroutines.flow.transform
|
||||
|
||||
object FavouriteStatusRouter {
|
||||
private val idGenerator = IntIdGenerator(Settings.dataMapNextId)
|
||||
@@ -79,5 +79,5 @@ object FavouriteStatusRouter {
|
||||
}
|
||||
}.shareIn(listenerScope, SharingStarted.Eagerly)
|
||||
|
||||
fun stateFlow(gid: Long) = globalFlow.filter { (gid1) -> gid1 == gid }
|
||||
fun stateFlow(targetGid: Long) = globalFlow.transform { (gid, slot) -> if (targetGid == gid) emit(slot) }
|
||||
}
|
||||
@@ -693,9 +693,7 @@ class GalleryDetailScene : BaseScene() {
|
||||
) {
|
||||
val favored by produceState(initialValue = false) {
|
||||
value = galleryDetail.favoriteSlot != -2
|
||||
FavouriteStatusRouter.stateFlow(galleryDetail.gid).collect { (_, slot) ->
|
||||
value = slot != -2
|
||||
}
|
||||
FavouriteStatusRouter.stateFlow(galleryDetail.gid).collect { value = it != -2 }
|
||||
}
|
||||
FilledTertiaryIconToggleButton(
|
||||
checked = favored,
|
||||
|
||||
Reference in new issue
Block a user