Обновление времени при записи, StorageMetaInfo
This commit is contained in:
@@ -3,5 +3,5 @@ package com.github.nullptroma.wallenc.presentation.extensions
|
||||
import com.github.nullptroma.wallenc.domain.interfaces.IStorageInfo
|
||||
|
||||
fun IStorageInfo.toPrintable(): String {
|
||||
return "{ uuid: $uuid, enc: ${encInfo.value} }"
|
||||
return "{ uuid: $uuid, enc: ${metaInfo.value.encInfo} }"
|
||||
}
|
||||
@@ -48,7 +48,9 @@ fun LocalVaultScreen(modifier: Modifier = Modifier,
|
||||
val available by it.isAvailable.collectAsStateWithLifecycle()
|
||||
val numOfFiles by it.numberOfFiles.collectAsStateWithLifecycle()
|
||||
val size by it.size.collectAsStateWithLifecycle()
|
||||
val enc by it.encInfo.collectAsStateWithLifecycle()
|
||||
val metaInfo by it.metaInfo.collectAsStateWithLifecycle()
|
||||
|
||||
val enc = metaInfo.encInfo
|
||||
Column {
|
||||
Text(it.uuid.toString())
|
||||
Text("IsAvailable: $available")
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.github.nullptroma.wallenc.domain.usecases.StorageFileManagementUseCas
|
||||
import com.github.nullptroma.wallenc.presentation.extensions.toPrintable
|
||||
import com.github.nullptroma.wallenc.presentation.viewmodel.ViewModelBase
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -21,15 +20,15 @@ import kotlin.system.measureTimeMillis
|
||||
|
||||
@HiltViewModel
|
||||
class LocalVaultViewModel @Inject constructor(
|
||||
private val _manageLocalVaultUseCase: ManageLocalVaultUseCase,
|
||||
private val _getOpenedStoragesUseCase: GetOpenedStoragesUseCase,
|
||||
private val _storageFileManagementUseCase: StorageFileManagementUseCase,
|
||||
private val manageLocalVaultUseCase: ManageLocalVaultUseCase,
|
||||
private val getOpenedStoragesUseCase: GetOpenedStoragesUseCase,
|
||||
private val storageFileManagementUseCase: StorageFileManagementUseCase,
|
||||
private val logger: ILogger
|
||||
) :
|
||||
ViewModelBase<LocalVaultScreenState>(LocalVaultScreenState(listOf())) {
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
_manageLocalVaultUseCase.localStorages.combine(_getOpenedStoragesUseCase.openedStorages) { local, opened ->
|
||||
manageLocalVaultUseCase.localStorages.combine(getOpenedStoragesUseCase.openedStorages) { local, opened ->
|
||||
local + (opened?.map { it.value } ?: listOf())
|
||||
}.collectLatest {
|
||||
val newState = state.value.copy(
|
||||
@@ -41,13 +40,13 @@ class LocalVaultViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun printStorageInfoToLog(storage: IStorageInfo) {
|
||||
_storageFileManagementUseCase.setStorage(storage)
|
||||
storageFileManagementUseCase.setStorage(storage)
|
||||
viewModelScope.launch {
|
||||
val files: List<IFile>
|
||||
val dirs: List<IDirectory>
|
||||
val time = measureTimeMillis {
|
||||
files = _storageFileManagementUseCase.getAllFiles()
|
||||
dirs = _storageFileManagementUseCase.getAllDirs()
|
||||
files = storageFileManagementUseCase.getAllFiles()
|
||||
dirs = storageFileManagementUseCase.getAllDirs()
|
||||
}
|
||||
for (file in files) {
|
||||
logger.debug("Files", file.metaInfo.toString())
|
||||
@@ -62,7 +61,7 @@ class LocalVaultViewModel @Inject constructor(
|
||||
|
||||
fun createStorage() {
|
||||
viewModelScope.launch {
|
||||
_manageLocalVaultUseCase.createStorage(EncryptKey("hello"))
|
||||
manageLocalVaultUseCase.createStorage(EncryptKey("hello"))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user