diff --git a/composeApp/src/commonMain/kotlin/com/clipevery/ui/devices/DevicesView.kt b/composeApp/src/commonMain/kotlin/com/clipevery/ui/devices/DevicesView.kt index 5adbaf653..f18de555f 100644 --- a/composeApp/src/commonMain/kotlin/com/clipevery/ui/devices/DevicesView.kt +++ b/composeApp/src/commonMain/kotlin/com/clipevery/ui/devices/DevicesView.kt @@ -15,6 +15,7 @@ import com.clipevery.dao.sync.SyncRuntimeInfo import com.clipevery.dao.sync.SyncRuntimeInfoDao import com.clipevery.ui.PageViewContext import kotlinx.coroutines.flow.asFlow +import kotlinx.coroutines.flow.toList @Composable fun DevicesView(currentPageViewContext: MutableState) { @@ -22,17 +23,15 @@ fun DevicesView(currentPageViewContext: MutableState) { val syncRuntimeInfoDao = current.koin.get() val syncRuntimeInfosFlow = syncRuntimeInfoDao.getAllSyncRuntimeInfos().asFlow() - var syncRuntimeInfos by remember { mutableStateOf(emptyList()) } + var rememberSyncRuntimeInfos by remember { mutableStateOf(emptyList()) } LaunchedEffect(syncRuntimeInfosFlow) { - syncRuntimeInfosFlow.collect { updatedUsers -> - syncRuntimeInfos = listOf(updatedUsers) - } + rememberSyncRuntimeInfos = syncRuntimeInfosFlow.toList() } - for ((index, syncRuntimeInfo) in syncRuntimeInfos.withIndex()) { + for ((index, syncRuntimeInfo) in rememberSyncRuntimeInfos.withIndex()) { DeviceItemView(syncRuntimeInfo, currentPageViewContext) - if (index != syncRuntimeInfos.size - 1) { + if (index != rememberSyncRuntimeInfos.size - 1) { Divider(modifier = Modifier.fillMaxWidth()) } }