storages в UnlockManager

This commit is contained in:
Пытков Роман
2025-02-11 18:17:19 +03:00
parent 85b8517a76
commit 824306d8bc
2 changed files with 8 additions and 3 deletions

View File

@@ -15,10 +15,12 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.withContext
@@ -45,7 +47,11 @@ class UnlockManager(
get() = MutableStateFlow(null)
override val storages: StateFlow<List<IStorage>?>
get() = TODO()
get() = openedStorages.map { it?.values?.toList() }.stateIn(
scope = CoroutineScope(ioDispatcher),
started = SharingStarted.WhileSubscribed(5000L),
initialValue = null
)
init {
CoroutineScope(ioDispatcher).launch {

View File

@@ -67,8 +67,7 @@ fun StorageTree(
val numOfFiles by cur.numberOfFiles.collectAsStateWithLifecycle()
val size by cur.size.collectAsStateWithLifecycle()
val metaInfo by cur.metaInfo.collectAsStateWithLifecycle()
//val isAvailable by cur.isAvailable.collectAsStateWithLifecycle()
val isAvailable = metaInfo.name?.startsWith("1") != true
val isAvailable by cur.isAvailable.collectAsStateWithLifecycle()
val borderColor =
if (cur.isVirtualStorage) MaterialTheme.colorScheme.secondary else MaterialTheme.colorScheme.primary
Column(modifier) {