@@ -7,6 +7,9 @@ import app.k9mail.feature.account.common.domain.entity.SpecialFolderSettings
77import app.k9mail.feature.account.setup.AccountSetupExternalContract
88import app.k9mail.feature.account.setup.AccountSetupExternalContract.AccountCreator.AccountCreatorResult
99import app.k9mail.feature.account.setup.domain.usecase.GetSpecialFolderOptions
10+ import app.k9mail.legacy.mailstore.MessageStoreManager
11+ import app.k9mail.legacy.mailstore.domain.GetFolderIdsForTypeUseCase
12+ import app.k9mail.legacy.mailstore.domain.SetPushForFolderUseCase
1013import com.fsck.k9.Core
1114import com.fsck.k9.Preferences
1215import com.fsck.k9.account.DeletePolicyProvider
@@ -48,6 +51,8 @@ internal class AccountCreator(
4851 private val avatarMonogramCreator : AvatarMonogramCreator ,
4952 private val unifiedInboxConfigurator : UnifiedInboxConfigurator ,
5053 private val featureFlagProvider : FeatureFlagProvider ,
54+ private val getFolderIdsForTypeUseCase : GetFolderIdsForTypeUseCase ,
55+ private val setPushForFolderUseCase : SetPushForFolderUseCase ,
5156 private val coroutineDispatcher : CoroutineDispatcher = Dispatchers .IO ,
5257) : AccountSetupExternalContract.AccountCreator {
5358
@@ -114,19 +119,12 @@ internal class AccountCreator(
114119 featureFlagProvider.provide(GeneratedFeatureFlagKey .PUSH_ENABLED_ON_INBOX_BY_DEFAULT )
115120 .onEnabled {
116121 // The AccountCreator is only called when not importing settings.
117- // We can update inbox push here by default.
118- // TODO Get Inbox folderDetails, then updateFolderSettings
119- // TODO make a use case for getting a folder's settings by type
120- val inboxFolderID: Long? =
121- messagingController.getMessageStore(newAccount).getFolders(true ) { folderDetails ->
122- if (folderDetails.type == FolderType .INBOX ) {
123- folderDetails.id
124- } else {
125- null
126- }
127- }.firstOrNull()
128- if (inboxFolderID != null ) {
129- messagingController.getMessageStore(newAccount).setPushEnabled(inboxFolderID, true )
122+ // We can update inbox push here by default, as it's always a new account.
123+ getFolderIdsForTypeUseCase(
124+ newAccount.uuid,
125+ FolderType .INBOX
126+ ).firstOrNull()?.let { inboxFolderId ->
127+ setPushForFolderUseCase(accountUuid = newAccount.uuid, folderId = inboxFolderId, enabled = true )
130128 }
131129 }
132130
0 commit comments