From 824306d8bc9fca648fbced27a0b26393932e1796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=8B=D1=82=D0=BA=D0=BE=D0=B2=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD?= Date: Tue, 11 Feb 2025 18:17:19 +0300 Subject: [PATCH] =?UTF-8?q?storages=20=D0=B2=20UnlockManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nullptroma/wallenc/data/storages/UnlockManager.kt | 8 +++++++- .../wallenc/presentation/elements/StorageTree.kt | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) 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) {