Skip to content

feat: Messages actions use case#2819

Open
solrubado wants to merge 33 commits intoprotected/refactor-mail-actionsfrom
messages-actions-use-case
Open

feat: Messages actions use case#2819
solrubado wants to merge 33 commits intoprotected/refactor-mail-actionsfrom
messages-actions-use-case

Conversation

@solrubado
Copy link
Copy Markdown
Contributor

@solrubado solrubado commented Feb 23, 2026

Depends on #2814

@solrubado solrubado changed the title Messages actions use case feat: Messages actions use case Feb 24, 2026
@github-actions github-actions bot added the dependent This MR depends on another PR label Feb 24, 2026
@FabianDevel FabianDevel force-pushed the messages-actions-use-case branch from b80a46a to 3a7ff5e Compare March 3, 2026 14:34
@solrubado solrubado force-pushed the network-management branch from e6d2918 to cde5dde Compare March 3, 2026 15:11
Base automatically changed from network-management to protected/refactor-mail-actions March 3, 2026 15:22
@github-actions github-actions bot removed the dependent This MR depends on another PR label Mar 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

This PR/issue depends on:

@solrubado solrubado force-pushed the messages-actions-use-case branch from 3a7ff5e to 3db2f00 Compare March 3, 2026 15:26
}

sealed class ApiCallResult {
data class Success(val messageRes: Int) : ApiCallResult()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you put a message in success ? I don't think we need it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We show a success message when we do a phishing report, block user and when we successfully undo an action.


private suspend fun moveOutThreadsLocally(messages: List<Message>, destinationFolder: Folder): List<String> {
val uidsToMove = mutableListOf<String>().apply {
messages.flatMapTo(mutableSetOf(), Message::threads).forEach { thread ->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you now open the realm to get the thread, why do you need to do it now ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is safer this way, the old code could access thread.messages and it.folderId on potentially deleted objects.

@solrubado solrubado force-pushed the messages-actions-use-case branch from e18fa08 to 9c6dbcf Compare March 23, 2026 14:11
Copy link
Copy Markdown
Contributor

@FabianDevel FabianDevel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!!)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this

downloadThreadsStatusManager.updateState(false)
}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this

threads.flatMap { thread ->
messageController.getLastMessageAndItsDuplicatesToExecuteAction(thread, mailbox.featureFlags)
}
} else threads.flatMap { thread -> messageController.getUnseenMessages(thread) }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always add the brackets when the whole if cannot be inlined

Comment on lines +259 to +262
messages = messages,
mailbox = mailbox,
threadsUids = threadsUids,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oneline this

fun updateState(isDownloading: Boolean) {
_isDownloading.value = isDownloading
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line


data class UndoData(
val resources: List<String>,
val resources: List<String>?,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to be nullable, and the code that checks this nullability will be useless

…ction

Since it will be just one message, filtering is not needed, filter is just for thread actions
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants