feat: Messages actions use case#2819
feat: Messages actions use case#2819solrubado wants to merge 33 commits intoprotected/refactor-mail-actionsfrom
Conversation
8a8e99a to
73350ef
Compare
b80a46a to
3a7ff5e
Compare
e6d2918 to
cde5dde
Compare
|
This PR/issue depends on:
|
3a7ff5e to
3db2f00
Compare
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ActionsViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| sealed class ApiCallResult { | ||
| data class Success(val messageRes: Int) : ApiCallResult() |
There was a problem hiding this comment.
Why did you put a message in success ? I don't think we need it
There was a problem hiding this comment.
We show a success message when we do a phishing report, block user and when we successfully undo an action.
app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt
Show resolved
Hide resolved
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ActionsViewModel.kt
Outdated
Show resolved
Hide resolved
|
|
||
| private suspend fun moveOutThreadsLocally(messages: List<Message>, destinationFolder: Folder): List<String> { | ||
| val uidsToMove = mutableListOf<String>().apply { | ||
| messages.flatMapTo(mutableSetOf(), Message::threads).forEach { thread -> |
There was a problem hiding this comment.
I see that you now open the realm to get the thread, why do you need to do it now ?
There was a problem hiding this comment.
It is safer this way, the old code could access thread.messages and it.folderId on potentially deleted objects.
app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt
Outdated
Show resolved
Hide resolved
e18fa08 to
9c6dbcf
Compare
FabianDevel
left a comment
There was a problem hiding this comment.
It appears when testing that the messages actions inside a thread may not work
| trackScheduleSendEvent(MatomoName.CustomScheduleConfirm) | ||
| localSettings.lastSelectedScheduleEpochMillis = timestamp | ||
| mainViewModel.rescheduleDraft(Date(timestamp)) | ||
| actionsViewModel.rescheduleDraft(Date(timestamp), mainViewModel.currentMailbox.value!!) |
There was a problem hiding this comment.
You should not add new code with this nullablility check
You can manage it like elsewhere with an error snackback
| threadController.updateIsLocallyMovedOutStatus(threadsUids, hasBeenMovedOut = false) | ||
| } | ||
| } | ||
|
|
| downloadThreadsStatusManager.updateState(false) | ||
| } | ||
|
|
||
|
|
| threads.flatMap { thread -> | ||
| messageController.getLastMessageAndItsDuplicatesToExecuteAction(thread, mailbox.featureFlags) | ||
| } | ||
| } else threads.flatMap { thread -> messageController.getUnseenMessages(thread) } |
There was a problem hiding this comment.
Always add the brackets when the whole if cannot be inlined
| messages = messages, | ||
| mailbox = mailbox, | ||
| threadsUids = threadsUids, | ||
| ) |
| fun updateState(isDownloading: Boolean) { | ||
| _isDownloading.value = isDownloading | ||
| } | ||
|
|
|
|
||
| data class UndoData( | ||
| val resources: List<String>, | ||
| val resources: List<String>?, |
There was a problem hiding this comment.
It doesn't need to be nullable, and the code that checks this nullability will be useless
…box with unsafe null operator
…ction Since it will be just one message, filtering is not needed, filter is just for thread actions
|



Depends on #2814