@@ -30,12 +30,9 @@ import com.infomaniak.mail.R
30
30
import com.infomaniak.mail.data.LocalSettings
31
31
import com.infomaniak.mail.data.api.ApiRepository
32
32
import com.infomaniak.mail.data.cache.RealmDatabase
33
- import com.infomaniak.mail.data.cache.mailboxContent.FolderController
34
- import com.infomaniak.mail.data.cache.mailboxContent.MessageController
35
- import com.infomaniak.mail.data.cache.mailboxContent.RefreshController
33
+ import com.infomaniak.mail.data.cache.mailboxContent.*
36
34
import com.infomaniak.mail.data.cache.mailboxContent.RefreshController.RefreshCallbacks
37
35
import com.infomaniak.mail.data.cache.mailboxContent.RefreshController.RefreshMode
38
- import com.infomaniak.mail.data.cache.mailboxContent.ThreadController
39
36
import com.infomaniak.mail.data.cache.mailboxInfo.MailboxController
40
37
import com.infomaniak.mail.data.cache.mailboxInfo.PermissionsController
41
38
import com.infomaniak.mail.data.cache.mailboxInfo.QuotasController
@@ -549,7 +546,8 @@ class MainViewModel @Inject constructor(
549
546
threadController.updateIsLocallyMovedOutStatus(threadsUids, hasBeenMovedOut = false )
550
547
551
548
val undoDestinationId = message?.folderId ? : threads.first().folderId
552
- val undoFoldersIds = (messages.getFoldersIds(exception = undoDestinationId) + trashId).filterNotNull()
549
+ val undoFoldersIds = messages.getFoldersIds(exception = undoDestinationId)
550
+ if (trashId != null ) undoFoldersIds + = trashId
553
551
showDeleteSnackbar(
554
552
apiResponses,
555
553
shouldPermanentlyDelete,
@@ -566,7 +564,7 @@ class MainViewModel @Inject constructor(
566
564
shouldPermanentlyDelete : Boolean ,
567
565
message : Message ? ,
568
566
undoResources : List <String >,
569
- undoFoldersIds : List < String > ,
567
+ undoFoldersIds : ImpactedFolders ,
570
568
undoDestinationId : String? ,
571
569
numberOfImpactedThreads : Int ,
572
570
) {
@@ -605,7 +603,7 @@ class MainViewModel @Inject constructor(
605
603
606
604
if (apiResponse.isSuccess() && mailbox.uuid == targetMailboxUuid) {
607
605
val draftFolderId = folderController.getFolder(FolderRole .DRAFT )!! .id
608
- refreshFoldersAsync(mailbox, listOf ( draftFolderId))
606
+ refreshFoldersAsync(mailbox, ImpactedFolders ( mutableSetOf ( draftFolderId) ))
609
607
}
610
608
611
609
showDeletedDraftSnackbar(apiResponse)
@@ -623,7 +621,7 @@ class MainViewModel @Inject constructor(
623
621
with (ApiRepository .rescheduleDraft(resource, scheduleDate)) {
624
622
if (isSuccess()) {
625
623
val scheduledDraftsFolderId = folderController.getFolder(FolderRole .SCHEDULED_DRAFTS )!! .id
626
- refreshFoldersAsync(currentMailbox.value!! , listOf ( scheduledDraftsFolderId))
624
+ refreshFoldersAsync(currentMailbox.value!! , ImpactedFolders ( mutableSetOf ( scheduledDraftsFolderId) ))
627
625
} else {
628
626
snackbarManager.postValue(title = appContext.getString(translatedError))
629
627
}
@@ -642,7 +640,7 @@ class MainViewModel @Inject constructor(
642
640
643
641
if (apiResponse.isSuccess()) {
644
642
val scheduledDraftsFolderId = folderController.getFolder(FolderRole .SCHEDULED_DRAFTS )!! .id
645
- refreshFoldersAsync(mailbox, listOf ( scheduledDraftsFolderId))
643
+ refreshFoldersAsync(mailbox, ImpactedFolders ( mutableSetOf ( scheduledDraftsFolderId) ))
646
644
onSuccess()
647
645
} else {
648
646
snackbarManager.postValue(title = appContext.getString(apiResponse.translatedError))
@@ -655,7 +653,7 @@ class MainViewModel @Inject constructor(
655
653
656
654
if (apiResponse.isSuccess()) {
657
655
val scheduledDraftsFolderId = folderController.getFolder(FolderRole .SCHEDULED_DRAFTS )!! .id
658
- refreshFoldersAsync(mailbox, listOf ( scheduledDraftsFolderId))
656
+ refreshFoldersAsync(mailbox, ImpactedFolders ( mutableSetOf ( scheduledDraftsFolderId) ))
659
657
}
660
658
661
659
showUnscheduledDraftSnackbar(apiResponse)
@@ -731,9 +729,11 @@ class MainViewModel @Inject constructor(
731
729
null
732
730
} else {
733
731
val undoDestinationId = message?.folderId ? : threads.first().folderId
732
+ val foldersIds = messages.getFoldersIds(exception = undoDestinationId)
733
+ foldersIds + = destinationFolder.id
734
734
UndoData (
735
735
resources = apiResponses.mapNotNull { it.data?.undoResource },
736
- foldersIds = messages.getFoldersIds(exception = undoDestinationId) + destinationFolder.id ,
736
+ foldersIds = foldersIds ,
737
737
destinationFolderId = undoDestinationId,
738
738
)
739
739
}
@@ -1111,7 +1111,7 @@ class MainViewModel @Inject constructor(
1111
1111
1112
1112
private fun refreshFoldersAsync (
1113
1113
mailbox : Mailbox ,
1114
- messagesFoldersIds : List < String > ,
1114
+ messagesFoldersIds : ImpactedFolders ,
1115
1115
destinationFolderId : String? = null,
1116
1116
callbacks : RefreshCallbacks ? = null,
1117
1117
) = viewModelScope.launch(ioCoroutineContext) {
0 commit comments