Skip to content

refactor: Actions should work with messages not only threads. #2795

Open
solrubado wants to merge 14 commits intomainfrom
threads-to-message-list
Open

refactor: Actions should work with messages not only threads. #2795
solrubado wants to merge 14 commits intomainfrom
threads-to-message-list

Conversation

@solrubado
Copy link
Contributor

No description provided.

@solrubado solrubado changed the title Refactor: Actions should work with messages not only threads. refactor: Actions should work with messages not only threads. Feb 2, 2026
@solrubado solrubado force-pushed the threads-to-message-list branch 2 times, most recently from b10b893 to 5fb3f9e Compare February 3, 2026 09:21
@FabianDevel FabianDevel force-pushed the threads-to-message-list branch 2 times, most recently from b6a55aa to 3548060 Compare February 10, 2026 14:37
Copy link
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.

I'm not sure we should keep the thread in the actionViewModel's function at all.
I believe we have all we need to directly pass the messages list to the functions

For now this feels a bit confusing between the function that accepts threads + messages, and the one that only accept messages but still used for threads too.

Comment on lines 171 to 173
val updatedSendersRestrictions = data!!.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.

Manage the !! with an error snackbar

//endregion

//region Move
fun moveThreadsOrMessagesTo(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should look how to remove this from the mainViewModel also, to avoid having duplicated logic.

Comment on lines 465 to 473
private fun refreshFoldersAsync(
mailbox: Mailbox,
messagesFoldersIds: ImpactedFolders,
currentFolderId: String? = null,
destinationFolderId: String? = null,
callbacks: RefreshCallbacks? = null,
) = viewModelScope.launch(ioCoroutineContext) {
sharedUtils.refreshFolders(mailbox, messagesFoldersIds, destinationFolderId, currentFolderId, callbacks)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Put this outside the action regions, at the bottom of the class

Comment on lines +795 to +819
fun trySendEmojiReply(
emoji: String,
messageUid: String,
reactions: Map<String, Reaction>,
hasNetwork: Boolean,
mailbox: Mailbox,
onAllowed: () -> Unit = {},
) {
viewModelScope.launch {
when (val status = reactions.getEmojiSendStatus(emoji, hasNetwork)) {
EmojiSendStatus.Allowed -> {
onAllowed()
sendEmojiReply(emoji, messageUid, mailbox)
}
is EmojiSendStatus.NotAllowed -> snackbarManager.postValue(appContext.getString(status.errorMessageRes))
}
}
}

private fun Map<String, Reaction>.getEmojiSendStatus(emoji: String, hasNetwork: Boolean): EmojiSendStatus = when {
this[emoji]?.hasReacted == true -> EmojiSendStatus.NotAllowed.AlreadyUsed
hasAvailableReactionSlot().not() -> EmojiSendStatus.NotAllowed.MaxReactionReached
hasNetwork.not() -> EmojiSendStatus.NotAllowed.NoInternet
else -> EmojiSendStatus.Allowed
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think all the emoji stuff should be left out of this viewModel, it's not directly linked to the actions

Comment on lines 828 to 829
if (hasFailedFetching) return
val draftMode = Draft.DraftMode.REPLY_ALL
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a blank line to separate the early return from the rest of the code

@solrubado solrubado force-pushed the threads-to-message-list branch from 3548060 to 96172ac Compare February 23, 2026 07:43
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
3.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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