Skip to content

Commit

Permalink
🐛 Fix device list display bug (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
guiyanakuang authored Feb 2, 2024
1 parent ef2656b commit b6dd036
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@ 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<PageViewContext>) {
val current = LocalKoinApplication.current
val syncRuntimeInfoDao = current.koin.get<SyncRuntimeInfoDao>()
val syncRuntimeInfosFlow = syncRuntimeInfoDao.getAllSyncRuntimeInfos().asFlow()

var syncRuntimeInfos by remember { mutableStateOf(emptyList<SyncRuntimeInfo>()) }
var rememberSyncRuntimeInfos by remember { mutableStateOf(emptyList<SyncRuntimeInfo>()) }

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())
}
}
Expand Down

0 comments on commit b6dd036

Please sign in to comment.