Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 789c1bc4 authored by Rafael Tonholo's avatar Rafael Tonholo Committed by GitHub
Browse files

Merge pull request #9763 from wmontwe/refactor-rename-legacy-account

refactor: rename legacy account
parents 21a1e2c1 c70dce79
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import com.fsck.k9.preferences.UnifiedInboxConfigurator
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import net.thunderbird.core.android.account.LegacyAccount
import net.thunderbird.core.android.account.LegacyAccountDto
import net.thunderbird.core.common.mail.Protocols
import net.thunderbird.core.logging.legacy.Log
import net.thunderbird.feature.account.avatar.AvatarMonogramCreator
@@ -113,7 +113,7 @@ internal class AccountCreator(
     * Since the folder list hasn't been synced yet, we don't have database IDs for the folders. So we use the same
     * mechanism that is used when importing settings. See [com.fsck.k9.mailstore.SpecialFolderUpdater] for details.
     */
    private fun LegacyAccount.setSpecialFolders(specialFolders: SpecialFolderSettings) {
    private fun LegacyAccountDto.setSpecialFolders(specialFolders: SpecialFolderSettings) {
        importedArchiveFolder = specialFolders.archiveSpecialFolderOption.toFolderServerId()
        archiveFolderSelection = specialFolders.archiveSpecialFolderOption.toFolderSelection()

@@ -153,7 +153,7 @@ internal class AccountCreator(
    }
}

private fun LegacyAccount.setIncomingServerSettings(serverSettings: ServerSettings) {
private fun LegacyAccountDto.setIncomingServerSettings(serverSettings: ServerSettings) {
    if (serverSettings.type == Protocols.IMAP) {
        useCompression = serverSettings.isUseCompression
        isSendClientInfoEnabled = serverSettings.isSendClientInfo
+4 −4
Original line number Diff line number Diff line
@@ -2,9 +2,9 @@ package net.thunderbird.app.common.account

import app.k9mail.feature.account.setup.AccountSetupExternalContract
import net.thunderbird.app.common.account.data.DefaultAccountProfileLocalDataSource
import net.thunderbird.app.common.account.data.DefaultLegacyAccountWrapperManager
import net.thunderbird.app.common.account.data.DefaultLegacyAccountManager
import net.thunderbird.core.android.account.AccountDefaultsProvider
import net.thunderbird.core.android.account.LegacyAccountWrapperManager
import net.thunderbird.core.android.account.LegacyAccountManager
import net.thunderbird.feature.account.avatar.AvatarMonogramCreator
import net.thunderbird.feature.account.avatar.DefaultAvatarMonogramCreator
import net.thunderbird.feature.account.core.AccountCoreExternalContract.AccountProfileLocalDataSource
@@ -19,8 +19,8 @@ internal val appCommonAccountModule = module {
        featureAccountStorageLegacyModule,
    )

    single<LegacyAccountWrapperManager> {
        DefaultLegacyAccountWrapperManager(
    single<LegacyAccountManager> {
        DefaultLegacyAccountManager(
            accountManager = get(),
            accountDataMapper = get(),
        )
+4 −4
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import net.thunderbird.core.android.account.AccountDefaultsProvider.Companion.UN
import net.thunderbird.core.android.account.Expunge
import net.thunderbird.core.android.account.FolderMode
import net.thunderbird.core.android.account.Identity
import net.thunderbird.core.android.account.LegacyAccount
import net.thunderbird.core.android.account.LegacyAccountDto
import net.thunderbird.core.android.account.ShowPictures
import net.thunderbird.core.featureflag.FeatureFlagProvider
import net.thunderbird.core.featureflag.toFeatureFlagKey
@@ -38,11 +38,11 @@ internal class DefaultAccountDefaultsProvider(
    private val featureFlagProvider: FeatureFlagProvider,
) : AccountDefaultsProvider {

    override fun applyDefaults(account: LegacyAccount) = with(account) {
    override fun applyDefaults(account: LegacyAccountDto) = with(account) {
        applyLegacyDefaults()
    }

    override fun applyOverwrites(account: LegacyAccount, storage: Storage) = with(account) {
    override fun applyOverwrites(account: LegacyAccountDto, storage: Storage) = with(account) {
        if (storage.contains("${account.uuid}.notifyNewMail")) {
            isNotifyNewMail = storage.getBoolean("${account.uuid}.notifyNewMail", false)
            isNotifySelfNewMail = storage.getBoolean("${account.uuid}.notifySelfNewMail", true)
@@ -64,7 +64,7 @@ internal class DefaultAccountDefaultsProvider(
    }

    @Suppress("LongMethod")
    private fun LegacyAccount.applyLegacyDefaults() {
    private fun LegacyAccountDto.applyLegacyDefaults() {
        automaticCheckIntervalMinutes = DEFAULT_SYNC_INTERVAL
        idleRefreshMinutes = 24
        displayCount = DEFAULT_VISIBLE_LIMIT
+2 −2
Original line number Diff line number Diff line
@@ -3,14 +3,14 @@ package net.thunderbird.app.common.account.data
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.map
import net.thunderbird.core.android.account.LegacyAccountWrapperManager
import net.thunderbird.core.android.account.LegacyAccountManager
import net.thunderbird.feature.account.AccountId
import net.thunderbird.feature.account.core.AccountCoreExternalContract.AccountProfileLocalDataSource
import net.thunderbird.feature.account.profile.AccountProfile
import net.thunderbird.feature.account.storage.mapper.AccountProfileDataMapper

internal class DefaultAccountProfileLocalDataSource(
    private val accountManager: LegacyAccountWrapperManager,
    private val accountManager: LegacyAccountManager,
    private val dataMapper: AccountProfileDataMapper,
) : AccountProfileLocalDataSource {

+7 −7
Original line number Diff line number Diff line
@@ -3,17 +3,17 @@ package net.thunderbird.app.common.account.data
import kotlinx.coroutines.flow.Flow
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.core.android.account.LegacyAccount
import net.thunderbird.core.android.account.LegacyAccountManager
import net.thunderbird.feature.account.AccountId
import net.thunderbird.feature.account.storage.legacy.mapper.DefaultLegacyAccountWrapperDataMapper

internal class DefaultLegacyAccountWrapperManager(
internal class DefaultLegacyAccountManager(
    private val accountManager: AccountManager,
    private val accountDataMapper: DefaultLegacyAccountWrapperDataMapper,
) : LegacyAccountWrapperManager {
) : LegacyAccountManager {

    override fun getAll(): Flow<List<LegacyAccountWrapper>> {
    override fun getAll(): Flow<List<LegacyAccount>> {
        return accountManager.getAccountsFlow()
            .map { list ->
                list.map { account ->
@@ -22,7 +22,7 @@ internal class DefaultLegacyAccountWrapperManager(
            }
    }

    override fun getById(id: AccountId): Flow<LegacyAccountWrapper?> {
    override fun getById(id: AccountId): Flow<LegacyAccount?> {
        return accountManager.getAccountFlow(id.asRaw()).map { account ->
            account?.let {
                accountDataMapper.toDomain(it)
@@ -30,7 +30,7 @@ internal class DefaultLegacyAccountWrapperManager(
        }
    }

    override suspend fun update(account: LegacyAccountWrapper) {
    override suspend fun update(account: LegacyAccount) {
        accountManager.saveAccount(
            accountDataMapper.toDto(account),
        )
Loading