Reduce allocation

This commit is contained in:
GG Bond authored and Vladimir Dostoyevskiy committed 2023-11-28 14:53:26 +08:00
1 parent d855858543
commit 9b3595e45f
1 file changed
+3 -4
@@ -248,10 +248,9 @@ object DownloadManager : OnSpiderListener {
@Stable
@Composable
fun collectDownloadState(gid: Long): State<Int> {
val flow = remember { stateFlow(gid).map { getDownloadState(it) } }
return flow.collectAsState(getDownloadState(gid))
}
fun collectDownloadState(gid: Long): State<Int> = remember {
notifyFlow.transform { if (it.gid == gid) emit(getDownloadState(gid)) }
}.collectAsState(getDownloadState(gid))
@Stable
@Composable