-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) -> |
There was a problem hiding this comment.
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"?
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. |
@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. |
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.