Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PermanentDeleteChecker to check if messages will be deleted permanently #7731

Closed
wants to merge 4 commits into from

Conversation

cketti
Copy link
Member

@cketti cketti commented Mar 20, 2024

It's surprisingly complex to find out whether deleting a message in the app will permanently delete this message, i.e. delete the local copy and the server copy (if available).

This is required functionality for #7707.

@cketti cketti requested a review from wmontwe as a code owner March 20, 2024 22:10
Copy link
Member

@wmontwe wmontwe left a comment

Choose a reason for hiding this comment

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

👍

Just some suggestions.

* Note: This only applies to local messages. What remote operation is performed when deleting a message is controlled
* by [Account.deletePolicy].
*/
internal class DeleteOperationDecider {
Copy link
Member

@wmontwe wmontwe Mar 26, 2024

Choose a reason for hiding this comment

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

👍

Maybe LocalDeleteOperationDecider reflects it's purpose better or change it to an interface and provide a default implementation.


sealed interface PermanentDeleteResult {
data object None : PermanentDeleteResult
data class Some(val permanentDeleteCount: Int) : PermanentDeleteResult
Copy link
Member

Choose a reason for hiding this comment

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

This could be Partial

@@ -223,6 +223,11 @@ class FolderRepository(
return messageStore.getFolder(folderId) { true } ?: false
}

fun isLocalFolder(account: Account, folderId: Long): Boolean {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe isLocalFolderOnly would describe it better.

Copy link
Member

Choose a reason for hiding this comment

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

This class could benefit from a test.

return deleteOperationDecider.isDeleteImmediately(account, folderId) && !isRemoteCopyKept(account, folderId)
}

private fun isRemoteCopyKept(account: Account, folderId: Long): Boolean {
Copy link
Member

@wmontwe wmontwe Mar 26, 2024

Choose a reason for hiding this comment

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

This could be a RemoteDeleteOperationDecider

private fun getPermanentDeleteCount(account: Account, messageReferences: List<MessageReference>): Int {
return messageReferences
.groupBy { it.folderId }
.map { (folderId, messageReferences) ->
Copy link
Member

Choose a reason for hiding this comment

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

This threats all MessageReference related to a specific folderId in the same way. Is it possible for certain messages to be marked as "do not delete"?

@cketti cketti added the status: needs work Issues that are pending further action or development label Apr 11, 2024
@cketti
Copy link
Member Author

cketti commented Apr 23, 2024

I'm not quite happy with this approach. Having to perform disk I/O to be able to display a confirmation dialog (#7707) feels wrong. I think we should change the message (list) loading code to include the information necessary to answer the question whether a delete operation will permanently delete the message.

Closing this PR. I will open new PRs with the useful refactorings from this PR.

@Philippe-Choquette
Copy link

Philippe-Choquette commented Oct 22, 2024

@cketti Have new PRs been opened for the required refactorings finally?

If the code provided the information to the email list for where each email is stored, it would not only allow for the delete confirmation to be implemented for the trash specifically, but it could also allow for the addition of folder labels within the email list. For example, if you add the "Junk" folder to the unified inbox (which is useful when your email provider has a crappy, over-agressive junk filter), it is useful to specify that this was flagged as junk right from the email list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs work Issues that are pending further action or development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants