Skip to content

feat: Messages actions use case#2819

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

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

Conversation

@solrubado
Copy link
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

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
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 3, 2026

} else {
FolderRole.SPAM
if (displaySnackbar && result != null) {
showMoveSnackbar(result.movedThreads, result.messages, result.apiResponses, result.destinationFolder)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
showMoveSnackbar(result.movedThreads, result.messages, result.apiResponses, result.destinationFolder)
with(result) { showMoveSnackbar(movedThreads, messages, apiResponses, destinationFolder) }

Comment on lines +549 to +551
restrictions.apply {
blockedSenders.removeIf { it.email == email }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
restrictions.apply {
blockedSenders.removeIf { it.email == email }
}
restrictions.blockedSenders.removeIf { it.email == email }

}

sealed class ApiCallResult {
data class Success(val messageRes: Int) : ApiCallResult()
Copy link
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

else -> listOf(message)
}

suspend fun getMessagesFromThreadsToMove(threads: List<Thread>): List<Message> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This and the getMessagesFromThreadsToMarkAsUnseen are different from the other getMessagesFromThreadTo
(threads vs thread)

Comment on lines +503 to +504
val result = messagesActionsUseCase.undoAction(undoData, mailbox)
val message = when (result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Put the result directly in when


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
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 ?

resources = apiResponses.mapNotNull { it.data?.undoResource },
foldersIds = foldersIds,
destinationFolderId = undoDestinationId,
threadsMovedCount > 0 || messagesMoved.count() > 1 -> appContext.resources.getQuantityString(
Copy link
Contributor

Choose a reason for hiding this comment

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

Add curly bracket and put the getQuantityString on a new line

Comment on lines +183 to +187
val destinationFolderRole = if (folderRole == FolderRole.SPAM) {
FolderRole.INBOX
} else {
FolderRole.SPAM
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Oneline this

Comment on lines +239 to +242
if (apiResponses.atLeastOneFailed()) threadController.updateIsLocallyMovedOutStatus(
threadsUids = uidsToMove,
hasBeenMovedOut = false,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (apiResponses.atLeastOneFailed()) threadController.updateIsLocallyMovedOutStatus(
threadsUids = uidsToMove,
hasBeenMovedOut = false,
)
if (apiResponses.atLeastOneFailed()) {
threadController.updateIsLocallyMovedOutStatus(
threadsUids = uidsToMove,
hasBeenMovedOut = false,
)
}

Comment on lines +244 to +245
val undoDestinationId = messagesToDelete.first().folderId
val undoFoldersIds = messagesToDelete.getFoldersIds(exception = undoDestinationId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are this necessary if there are no undo action possible ?

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