diff --git a/data/src/main/java/com/github/nullptroma/wallenc/data/storages/UnlockManager.kt b/data/src/main/java/com/github/nullptroma/wallenc/data/storages/UnlockManager.kt index 47523b7..55bcab8 100644 --- a/data/src/main/java/com/github/nullptroma/wallenc/data/storages/UnlockManager.kt +++ b/data/src/main/java/com/github/nullptroma/wallenc/data/storages/UnlockManager.kt @@ -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?> - get() = TODO() + get() = openedStorages.map { it?.values?.toList() }.stateIn( + scope = CoroutineScope(ioDispatcher), + started = SharingStarted.WhileSubscribed(5000L), + initialValue = null + ) init { CoroutineScope(ioDispatcher).launch { diff --git a/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/elements/StorageTree.kt b/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/elements/StorageTree.kt index 3d171d1..0122f72 100644 --- a/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/elements/StorageTree.kt +++ b/presentation/src/main/java/com/github/nullptroma/wallenc/presentation/elements/StorageTree.kt @@ -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) {