Add support for retrieving a single send by ID from the VaultRepository (#564)

This commit is contained in:
David Perez
2024-01-10 13:31:31 -06:00
committed by Álison Fernandes
parent 75a08e72a6
commit f8ff7c225d
3 changed files with 89 additions and 0 deletions

View File

@@ -93,6 +93,12 @@ interface VaultRepository : VaultLockManager {
*/
fun getVaultFolderStateFlow(folderId: String): StateFlow<DataState<FolderView?>>
/**
* Flow that represents the data for a specific send as found by ID. This may emit `null` if
* the send cannot be found.
*/
fun getSendStateFlow(sendId: String): StateFlow<DataState<SendView?>>
/**
* Emits the totp code result flow to listeners.
*/

View File

@@ -263,6 +263,19 @@ class VaultRepositoryImpl(
initialValue = DataState.Loading,
)
override fun getSendStateFlow(sendId: String): StateFlow<DataState<SendView?>> =
sendDataStateFlow
.map { dataState ->
dataState.map { sendData ->
sendData.sendViewList.find { it.id == sendId }
}
}
.stateIn(
scope = unconfinedScope,
started = SharingStarted.Lazily,
initialValue = DataState.Loading,
)
override fun emitTotpCodeResult(totpCodeResult: TotpCodeResult) {
mutableTotpCodeResultFlow.tryEmit(totpCodeResult)
}