package com.github.nullptroma.wallenc.usecases

import com.github.nullptroma.wallenc.domain.interfaces.IStorage
import com.github.nullptroma.wallenc.domain.interfaces.IVaultsManager
import java.util.UUID
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class FindStorageUseCase @Inject constructor(
    private val vaultsManager: IVaultsManager,
) {
    fun find(storageUuid: UUID): IStorage? {
        return (
            vaultsManager.allStorages.value +
                vaultsManager.unlockManager.openedStorages.value.values
            )
            .distinctBy { it.uuid }
            .firstOrNull { it.uuid == storageUuid }
    }
}
