Loading app-common/src/main/kotlin/net/thunderbird/app/common/account/data/DefaultAccountProfileLocalDataSource.kt +2 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ internal class DefaultAccountProfileLocalDataSource( ) : AccountProfileLocalDataSource { override fun getById(accountId: AccountId): Flow<AccountProfile?> { return accountManager.getById(accountId.asRaw()) return accountManager.getById(accountId) .map { account -> account?.let { dto -> dataMapper.toDomain(dto.profile) Loading @@ -24,7 +24,7 @@ internal class DefaultAccountProfileLocalDataSource( } override suspend fun update(accountProfile: AccountProfile) { val currentAccount = accountManager.getById(accountProfile.id.asRaw()) val currentAccount = accountManager.getById(accountProfile.id) .firstOrNull() ?: return val accountProfile = dataMapper.toDto(accountProfile) Loading app-common/src/main/kotlin/net/thunderbird/app/common/account/data/DefaultLegacyAccountWrapperManager.kt +3 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import kotlinx.coroutines.flow.map import net.thunderbird.core.android.account.AccountManager import net.thunderbird.core.android.account.LegacyAccountWrapper import net.thunderbird.core.android.account.LegacyAccountWrapperManager import net.thunderbird.feature.account.AccountId import net.thunderbird.feature.account.storage.legacy.mapper.DefaultLegacyAccountWrapperDataMapper internal class DefaultLegacyAccountWrapperManager( Loading @@ -21,8 +22,8 @@ internal class DefaultLegacyAccountWrapperManager( } } override fun getById(id: String): Flow<LegacyAccountWrapper?> { return accountManager.getAccountFlow(id).map { account -> override fun getById(id: AccountId): Flow<LegacyAccountWrapper?> { return accountManager.getAccountFlow(id.asRaw()).map { account -> account?.let { accountDataMapper.toDomain(it) } Loading app-common/src/test/kotlin/net/thunderbird/app/common/account/data/FakeLegacyAccountWrapperManager.kt +4 −3 Original line number Diff line number Diff line Loading @@ -7,21 +7,22 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.update import net.thunderbird.core.android.account.LegacyAccountWrapper import net.thunderbird.core.android.account.LegacyAccountWrapperManager import net.thunderbird.feature.account.AccountId internal class FakeLegacyAccountWrapperManager( initialAccounts: List<LegacyAccountWrapper> = emptyList(), ) : LegacyAccountWrapperManager { private val accountsState = MutableStateFlow<List<LegacyAccountWrapper>>( private val accountsState = MutableStateFlow( initialAccounts, ) private val accounts: StateFlow<List<LegacyAccountWrapper>> = accountsState override fun getAll(): Flow<List<LegacyAccountWrapper>> = accounts override fun getById(id: String): Flow<LegacyAccountWrapper?> = accounts override fun getById(id: AccountId): Flow<LegacyAccountWrapper?> = accounts .map { list -> list.find { it.uuid == id } list.find { it.id == id } } override suspend fun update(account: LegacyAccountWrapper) { Loading core/android/account/src/main/kotlin/net/thunderbird/core/android/account/LegacyAccountWrapperManager.kt +2 −1 Original line number Diff line number Diff line package net.thunderbird.core.android.account import kotlinx.coroutines.flow.Flow import net.thunderbird.feature.account.AccountId interface LegacyAccountWrapperManager { fun getAll(): Flow<List<LegacyAccountWrapper>> fun getById(id: String): Flow<LegacyAccountWrapper?> fun getById(id: AccountId): Flow<LegacyAccountWrapper?> suspend fun update(account: LegacyAccountWrapper) } Loading
app-common/src/main/kotlin/net/thunderbird/app/common/account/data/DefaultAccountProfileLocalDataSource.kt +2 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ internal class DefaultAccountProfileLocalDataSource( ) : AccountProfileLocalDataSource { override fun getById(accountId: AccountId): Flow<AccountProfile?> { return accountManager.getById(accountId.asRaw()) return accountManager.getById(accountId) .map { account -> account?.let { dto -> dataMapper.toDomain(dto.profile) Loading @@ -24,7 +24,7 @@ internal class DefaultAccountProfileLocalDataSource( } override suspend fun update(accountProfile: AccountProfile) { val currentAccount = accountManager.getById(accountProfile.id.asRaw()) val currentAccount = accountManager.getById(accountProfile.id) .firstOrNull() ?: return val accountProfile = dataMapper.toDto(accountProfile) Loading
app-common/src/main/kotlin/net/thunderbird/app/common/account/data/DefaultLegacyAccountWrapperManager.kt +3 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import kotlinx.coroutines.flow.map import net.thunderbird.core.android.account.AccountManager import net.thunderbird.core.android.account.LegacyAccountWrapper import net.thunderbird.core.android.account.LegacyAccountWrapperManager import net.thunderbird.feature.account.AccountId import net.thunderbird.feature.account.storage.legacy.mapper.DefaultLegacyAccountWrapperDataMapper internal class DefaultLegacyAccountWrapperManager( Loading @@ -21,8 +22,8 @@ internal class DefaultLegacyAccountWrapperManager( } } override fun getById(id: String): Flow<LegacyAccountWrapper?> { return accountManager.getAccountFlow(id).map { account -> override fun getById(id: AccountId): Flow<LegacyAccountWrapper?> { return accountManager.getAccountFlow(id.asRaw()).map { account -> account?.let { accountDataMapper.toDomain(it) } Loading
app-common/src/test/kotlin/net/thunderbird/app/common/account/data/FakeLegacyAccountWrapperManager.kt +4 −3 Original line number Diff line number Diff line Loading @@ -7,21 +7,22 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.update import net.thunderbird.core.android.account.LegacyAccountWrapper import net.thunderbird.core.android.account.LegacyAccountWrapperManager import net.thunderbird.feature.account.AccountId internal class FakeLegacyAccountWrapperManager( initialAccounts: List<LegacyAccountWrapper> = emptyList(), ) : LegacyAccountWrapperManager { private val accountsState = MutableStateFlow<List<LegacyAccountWrapper>>( private val accountsState = MutableStateFlow( initialAccounts, ) private val accounts: StateFlow<List<LegacyAccountWrapper>> = accountsState override fun getAll(): Flow<List<LegacyAccountWrapper>> = accounts override fun getById(id: String): Flow<LegacyAccountWrapper?> = accounts override fun getById(id: AccountId): Flow<LegacyAccountWrapper?> = accounts .map { list -> list.find { it.uuid == id } list.find { it.id == id } } override suspend fun update(account: LegacyAccountWrapper) { Loading
core/android/account/src/main/kotlin/net/thunderbird/core/android/account/LegacyAccountWrapperManager.kt +2 −1 Original line number Diff line number Diff line package net.thunderbird.core.android.account import kotlinx.coroutines.flow.Flow import net.thunderbird.feature.account.AccountId interface LegacyAccountWrapperManager { fun getAll(): Flow<List<LegacyAccountWrapper>> fun getById(id: String): Flow<LegacyAccountWrapper?> fun getById(id: AccountId): Flow<LegacyAccountWrapper?> suspend fun update(account: LegacyAccountWrapper) }