Skip to content

feat: Messages actions use case#2819

Open
solrubado wants to merge 61 commits into
protected/refactor-mail-actionsfrom
messages-actions-use-case
Open

feat: Messages actions use case#2819
solrubado wants to merge 61 commits into
protected/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
Comment thread app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ActionsViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActions.kt
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActions.kt
Comment thread app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ActionsViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt Outdated
@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

Comment thread app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadFragment.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/utils/DownloadThreadsStatusManager.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/main/SnackbarManager.kt Outdated
@solrubado solrubado force-pushed the messages-actions-use-case branch from 6a03b28 to c51c111 Compare April 15, 2026 14:39
@solrubado solrubado force-pushed the protected/refactor-mail-actions branch 2 times, most recently from e8077b7 to 86a961b Compare April 16, 2026 07:23
@solrubado solrubado force-pushed the messages-actions-use-case branch from c51c111 to bd50647 Compare April 16, 2026 07:29
@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2814 - Partially compliant

Compliant requirements:

  • Refactored message actions into dedicated use case (MessagesActionsUseCase)
  • Centralized API calls within the use case layer
  • Separated business logic from ViewModels into use cases
  • Removed direct ApiRepository calls from ViewModels

Non-compliant requirements:

Requires further human verification:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Auto-Advance Logic

The refactoring removed the shouldAutoAdvance check that was previously present in moveThreadsOrMessageTo. When moving threads/messages succeeds (e.g., in createNewFolderAndMove), the UI should auto-advance to the next item if applicable. This logic is missing in the new implementation at lines 722-730, potentially causing the UI to remain on the moved item instead of advancing.

    val result = messagesActionsUseCase.moveThreadsOrMessagesTo(
        destinationFolderId = newFolderId,
        threadsUids = threadsUids,
        messagesUids = messagesUids,
        mailbox = mailbox,
        currentFolderId = currentFolderId,
    ) ?: run {
        snackbarManager.postValue(appContext.getString(RCore.string.anErrorHasOccurred))
        return@launch
    }

    with(result) {
        if (apiResponses.atLeastOneSucceeded()) {
            refreshFoldersAsync(
                mailbox = currentMailbox.value!!,
                messagesFoldersIds = messages.getFoldersIds(),
                destinationFolderId = newFolderId,
                threadsUids = threadsUids,
            )
            showMoveSnackbar(threadsUids.count(), messages, apiResponses, destinationFolder)
            isMovedToNewFolder.postValue(true)
        }

        if (apiResponses.atLeastOneFailed()) {
            threadController.updateIsLocallyMovedOutStatus(threadsUids, hasBeenMovedOut = false)
        }
    }
}
Redundant Variable Shadowing

Lines 604 and 622 contain redundant variable declarations val mailbox = mailbox that shadow the function parameters. This unnecessary code should be removed to improve readability and avoid confusion.

val mailbox = mailbox

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@solrubado solrubado force-pushed the messages-actions-use-case branch 2 times, most recently from 0a9d707 to 0f88aa1 Compare May 6, 2026 09:02
@solrubado solrubado requested a review from Copilot May 7, 2026 13:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a centralized “messages/thread actions” use case and refactors multiple UI entry points (thread list, thread view, bottom sheets, notifications, search) to route actions through this new layer, alongside related UX improvements (search contact suggestions, section headers) and supporting infrastructure (download status + network availability).

Changes:

  • Add MessagesActionsUseCase and refactor message/thread actions (move/delete/spam/seen/favorite/snooze/undo/phishing/block) to use it across the app.
  • Enhance notifications to include avatar/large icon support and migrate notification payload transport toward Parcelable usage.
  • Improve search results rendering (contacts + section titles) and thread list UX (section title item, swipe-to-switch account gesture).

Reviewed changes

Copilot reviewed 84 out of 85 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
fastlane/metadata/android/fr/changelogs/1_26_001_01.txt Add FR changelog entry for admin-disabled sending snackbar.
fastlane/metadata/android/fr/changelogs/1_26_000_01.txt Add FR changelog entries for phishing report, BIMI in notifications, network check fix.
fastlane/metadata/android/fr/changelogs/1_25_000_01.txt Add FR changelog entries for account swipe, reactions, emoji translations, misc fixes.
fastlane/metadata/android/en-US/changelogs/1_26_001_01.txt Add EN changelog entry for admin-disabled sending snackbar.
fastlane/metadata/android/en-US/changelogs/1_26_000_01.txt Add EN changelog entries for phishing report, BIMI notifications, network status fix.
fastlane/metadata/android/en-US/changelogs/1_25_000_01.txt Add EN changelog entries for account swipe, reactions, emoji translations, misc fixes.
app/src/test/java/com/infomaniak/mail/FolderRoleUtilsTest.kt Update tests for renamed folder-role helpers.
app/src/main/res/values/strings.xml Add/adjust strings & plurals for delete confirmation, spam actions, unknown tags, admin-disabled sending.
app/src/main/res/values/non_translatable_strings.xml Add Sentry error string for null mailbox.
app/src/main/res/values/dimens.xml Adjust toolbar width and add gesture/search spacing dimens.
app/src/main/res/values-sv/strings.xml Add new strings/plurals for scheduled delete confirmation + spam/admin-disabled sending/unknown tags.
app/src/main/res/values-pt/strings.xml Add new strings/plurals and update tools:ignore for quantities.
app/src/main/res/values-pl/strings.xml Add new strings/plurals for scheduled delete confirmation + spam/admin-disabled sending/unknown tags.
app/src/main/res/values-nl/strings.xml Add new strings/plurals and fix punctuation in a bold snippet.
app/src/main/res/values-nb/strings.xml Add new strings/plurals for scheduled delete confirmation + spam/admin-disabled sending/unknown tags.
app/src/main/res/values-it/strings.xml Add new strings/plurals and adjust punctuation consistency.
app/src/main/res/values-fr/strings.xml Add new strings/plurals and update tools:ignore for quantities.
app/src/main/res/values-fi/strings.xml Add new strings/plurals for scheduled delete confirmation + spam/admin-disabled sending/unknown tags.
app/src/main/res/values-es/strings.xml Add new strings/plurals and tweak several translations.
app/src/main/res/values-el/strings.xml Add new strings/plurals and tweak punctuation.
app/src/main/res/values-de/strings.xml Add new strings/plurals and tweak punctuation.
app/src/main/res/values-da/strings.xml Add new strings/plurals for scheduled delete confirmation + spam/admin-disabled sending/unknown tags.
app/src/main/res/navigation/main_navigation.xml Update folder picker argument from single message UID to array of message UIDs.
app/src/main/res/layout/item_thread_section_title.xml New list item layout for section headers.
app/src/main/res/layout/item_spacer_small.xml New list item layout for a small spacer row.
app/src/main/res/layout/item_contact_search.xml New list item layout for contact suggestions in search results.
app/src/main/res/layout/fragment_new_message.xml Remove camera/schedule editor buttons from compose toolbar.
app/src/main/res/layout/cardview_thread_item.xml Replace hardcoded unread bullet size with a dimen.
app/src/main/res/drawable/ic_editor_camera.xml Remove unused camera icon vector.
app/src/main/java/com/infomaniak/mail/views/itemViews/AvatarMergedContactData.kt Refine merged contacts + BIMI-enabled flows exposed as LiveData.
app/src/main/java/com/infomaniak/mail/utils/ThreadListUtils.kt New utility to compute section titles for threads by date.
app/src/main/java/com/infomaniak/mail/utils/SharedUtils.kt Refactor refresh-folder callback wiring for download-status handling.
app/src/main/java/com/infomaniak/mail/utils/NotificationUtils.kt Add avatar-derived large icon support for message notifications.
app/src/main/java/com/infomaniak/mail/utils/NotificationPayload.kt Expand notification payload to include sender/BIMI state and make it Parcelable.
app/src/main/java/com/infomaniak/mail/utils/NetworkManager.kt Add a StateFlow-backed network availability facade.
app/src/main/java/com/infomaniak/mail/utils/MessageUtils.kt Factor out junk-message user-to-block extraction for message lists.
app/src/main/java/com/infomaniak/mail/utils/FolderRoleUtils.kt Rework folder-role resolution for messages vs thread-level role needs.
app/src/main/java/com/infomaniak/mail/utils/FetchMessagesManager.kt Build richer notification payloads (sender + BIMI) and pass merged contacts.
app/src/main/java/com/infomaniak/mail/utils/extensions/Extensions.kt Add thread UID list helper and update sticky header detection to new item type.
app/src/main/java/com/infomaniak/mail/utils/extensions/ConfirmationPopupExt.kt Update delete confirmation to support multi-folder-role cases and scheduled messages wording.
app/src/main/java/com/infomaniak/mail/utils/ErrorCode.kt Add API error code mapping for admin-disabled message sending snackbar.
app/src/main/java/com/infomaniak/mail/utils/DownloadThreadsStatusManager.kt New download-status StateFlow manager for refresh/loading UX.
app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt New core use case consolidating message/thread action business logic.
app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageViewModel.kt Route “mark previous message as read” through the new actions use case.
app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt Fetch mailbox once before wiring send buttons/external banner behavior.
app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageExternalsManager.kt Parameterize external banner strings based on organization presence.
app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageEditorManager.kt Remove camera editor action wiring.
app/src/main/java/com/infomaniak/mail/ui/MainActivity.kt Use ActionsViewModel for dialog loader reset and draft/snackbar operations.
app/src/main/java/com/infomaniak/mail/ui/main/user/SwitchUserViewModel.kt Replace SingleLiveEvent accounts loading with SharedFlow-based emission.
app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadViewModel.kt Route “mark thread as seen” via use case and refresh on success.
app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadFragment.kt Migrate many thread actions to ActionsViewModel/EmojiReactionsViewModel and adjust subject tag click handling.
app/src/main/java/com/infomaniak/mail/ui/main/thread/SubjectFormatter.kt Support “unknown/external” tag variants and callback signature for tag dialogs.
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ThreadActionsBottomSheetDialog.kt Route thread actions via ActionsViewModel, update delete confirmation for message roles.
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MultiSelectBottomSheetDialog.kt Route multiselect actions via ActionsViewModel and improve mailbox-null handling.
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MessageActionsBottomSheetDialog.kt Route message actions via ActionsViewModel and update folder picker args to messagesUids.
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/JunkMessagesViewModel.kt Add a “messages” input path for single-message action sheets.
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/EmojiReactionsViewModel.kt New view model to validate/send emoji reactions with network gating.
app/src/main/java/com/infomaniak/mail/ui/main/search/SearchViewModel.kt Add combined contacts+threads search results formatting with section titles and contact suggestions.
app/src/main/java/com/infomaniak/mail/ui/main/search/SearchFragment.kt Collect combined search results flow and clear search state on back/navigation.
app/src/main/java/com/infomaniak/mail/ui/main/folderPicker/FolderPickerFragment.kt Route move actions via ActionsViewModel and support multiple message UIDs.
app/src/main/java/com/infomaniak/mail/ui/main/folder/TwoPaneFragment.kt Make handleOnBackPressed overridable and expose ActionsViewModel.
app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListMultiSelection.kt Route multiselect quick actions via ActionsViewModel and update role resolution.
app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListFragment.kt Use new download status manager, add avatar swipe gesture to switch accounts, route emoji reactions via new VM.
app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListAdapterCallbacks.kt Add callback for contact search result item clicks.
app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListAdapter.kt Support new list items (section title/contact/spacer) and update section-title computation.
app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadItem.kt Extend ThreadListItem types for section titles, contacts, and spacer.
app/src/main/java/com/infomaniak/mail/ui/main/folder/PerformSwipeActionManager.kt Route swipe actions via ActionsViewModel and improve mailbox-null safety.
app/src/main/java/com/infomaniak/mail/ui/main/AvatarNameEmailView.kt Add helpers for adjusting avatar margin and background for new search contact item UI.
app/src/main/java/com/infomaniak/mail/ui/bottomSheetDialogs/AccountBottomSheetDialog.kt Consume SharedFlow accounts list to populate account switcher.
app/src/main/java/com/infomaniak/mail/receivers/NotificationActionsReceiver.kt Adapt notification actions flow to new use case + contacts injection (but payload transport needs adjustment).
app/src/main/java/com/infomaniak/mail/MatomoMail.kt Remove camera-related Matomo event name.
app/src/main/java/com/infomaniak/mail/data/models/mailbox/MailboxLinkedResult.kt Remove unused mailbox-linked result model.
app/src/main/java/com/infomaniak/mail/data/models/correspondent/Recipient.kt Adjust interfaces implemented after Correspondent becomes Parcelable.
app/src/main/java/com/infomaniak/mail/data/models/correspondent/MergedContact.kt Adjust interfaces implemented after Correspondent becomes Parcelable.
app/src/main/java/com/infomaniak/mail/data/models/correspondent/Correspondent.kt Make Correspondent Parcelable to support Parcelable payload transport.
app/src/main/java/com/infomaniak/mail/data/models/calendar/Attendee.kt Adjust interfaces implemented after Correspondent becomes Parcelable.
app/src/main/java/com/infomaniak/mail/data/cache/userInfo/MergedContactController.kt Add Realm query helper to search merged contacts with accent-insensitive matching.
app/src/main/java/com/infomaniak/mail/data/cache/mailboxContent/MessageController.kt Add helpers for “all thread messages”, unscheduled filtering, and duplicates resolution.
app/src/main/java/com/infomaniak/mail/data/api/ApiRoutes.kt Remove unused mailbox-password management routes and reorder imports.
app/src/main/java/com/infomaniak/mail/data/api/ApiRepository.kt Remove unused mailbox-linking API method.
app/build.gradle.kts Bump app version to 1.26.1 / versionCode 1_26_001_01.
.github/workflows/euria-review.yml Remove Euria Review workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActions.kt
@solrubado solrubado force-pushed the protected/refactor-mail-actions branch from c02cf10 to 977f0e7 Compare May 7, 2026 14:02
@solrubado solrubado force-pushed the messages-actions-use-case branch from 1e413f8 to c9efef7 Compare May 8, 2026 07:57
@solrubado solrubado requested a review from Copilot May 8, 2026 07:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated 4 comments.

Comment thread app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ActionsViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated 5 comments.

Comment thread app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ActionsViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/utils/NetworkManager.kt
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated 5 comments.

Comment thread app/src/main/java/com/infomaniak/mail/utils/NetworkManager.kt
Comment thread app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadFragment.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/utils/FolderRoleUtils.kt
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActionsUseCase.kt Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated 3 comments.

Comment thread app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/utils/NetworkManager.kt
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated 6 comments.

Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActions.kt
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActions.kt
Comment thread app/src/main/java/com/infomaniak/mail/useCases/MessagesActions.kt
Comment thread app/src/main/java/com/infomaniak/mail/utils/NetworkManager.kt
Comment thread app/src/main/java/com/infomaniak/mail/utils/SharedUtils.kt
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 13, 2026

Quality Gate Passed Quality Gate passed

Issues
0 New issues
2 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants