-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Remove junk menu duplicate #2770
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
base: main
Are you sure you want to change the base?
Conversation
ace22c9 to
07985ea
Compare
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MailActionsBottomSheetDialog.kt
Outdated
Show resolved
Hide resolved
e19c156 to
246d695
Compare
LunarX
left a comment
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.
Somes first change requests
| fun hideReportJunkButtons() = with(binding) { | ||
| spam.isGone = true | ||
| phishing.isGone = true | ||
| blockSender.isGone = true | ||
| } |
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.
If this method is only used by MessageActionsBottomSheetDialog, can probably keep it private and define it inside the only class that uses it
| fun onSpam() = Unit | ||
| fun onPhishing() = Unit | ||
| fun onBlockSender() = Unit |
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.
No need for default implementations here
| val (text, icon) = if (isFromSpam) { | ||
| R.string.actionNonSpam to R.drawable.ic_non_spam | ||
| } else { | ||
| R.string.actionSpam to R.drawable.ic_report_junk |
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.
The icon is not correct. You are using the report junk icon instead of the spam icon. Also if the report_junk icon is not used anymore in the app we can remove it altogether
| val (text, icon) = if (isFromSpam) { | ||
| R.string.actionNonSpam to R.drawable.ic_non_spam | ||
| } else { | ||
| R.string.actionSpam to R.drawable.ic_report_junk | ||
| } |
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.
I see we have to setup the ui dynamically for all three junk items in two different places. We can extract a setJunkUi method and reuse it in both places
| } | ||
|
|
||
| phishing.isVisible = !isFromSpam | ||
| blockSender.isVisible = !isFromSpam |
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.
There used to be other conditions to hide/show the block sender. For exemple the option is not visible when the only email address that can be blocked is yourself. Now you show this button regardless of this condition
| blockSender.isVisible = !isFromSpam | ||
| } | ||
|
|
||
| private fun observeReportPhishingResult() { | ||
| mainViewModel.reportPhishingTrigger.observe(viewLifecycleOwner) { | ||
| descriptionDialog.resetLoadingAndDismiss() | ||
| findNavController().popBackStack() | ||
| } | ||
| } | ||
|
|
||
| private fun setBlockUserUi(potentialUsersToBlock: Map<Recipient, Message>) { | ||
| if (potentialUsersToBlock.count() == 0) binding.blockSender.isGone = true | ||
| } |
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.
Here you compute the blockSender visibility in two different spots which is error prone and could easily lead to hidden bugs when refactoring the code or moving the code around.
Also the 1st spot computes a condition A and the 2nd spot computes a condition B but the 1st spot doesn't care about condition B and the 2nd spot doesn't care about condition A. So only one of the two condition is effective
| // Check the first message, because it is not possible to select messages from multiple folders, | ||
| // so you won't have both SPAM and non-SPAM messages. | ||
| trackBottomSheetThreadActionsEvent( | ||
| MatomoName.Spam, | ||
| value = thread.messages.firstOrNull()?.folder?.role == FolderRole.SPAM |
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.
Can the condition for the matomo event be hardcoded to false here or is it different?
|
|
||
| descriptionDialog.show( | ||
| title = getString(R.string.reportPhishingTitle), | ||
| description = resources.getQuantityString(R.plurals.reportPhishingDescription, threadsCount), |
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.
I see that the quantity to select the singular or plural form of the string used to be computed based on the number of messages. Here you've changed it to the number of threads which is not the same. If you have a single thread with 2 messages, the string should be in plural to match the previous logic
| onPositiveButtonClicked = { | ||
| mainViewModel.reportPhishing( | ||
| threadsUids, | ||
| messages | ||
| ) | ||
| }, |
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 is more of a detail on the style of writing but we usually tend to one-line lines like those. If you look at what was there previously it's actually how it used to be written.
| onPositiveButtonClicked = { | |
| mainViewModel.reportPhishing( | |
| threadsUids, | |
| messages | |
| ) | |
| }, | |
| onPositiveButtonClicked = { mainViewModel.reportPhishing(threadsUids, messages) }, |
|
|
||
|
|
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.
Here we usually avoid double new lines in this situation
| --> | ||
| <resources> | ||
| <string name="errorPotentialUsersToBlockNull" translatable="false">Potential users to block is null</string> | ||
| <string name="errorPhishingMessagesNull" translatable="false">Phishing messages report failed because the list is empty</string> |
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.
Could we maybe name all sentry related strings by prefixing them with sentry... to better group them and distinguish them from other non-sentry string that have translatable="false" ?
|
|
||
| if (messages.isEmpty()) { | ||
| //An error will be shown to the user in the reportPhishing function | ||
| SentryLog.e(TAG, getString(R.string.errorPhishingMessagesNull)) |
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.
Should we not avoid showing the descriptionDialog if we detect that messages are empty and we already know that the dialog can never succeed?
|
|
||
| if (messages.isEmpty()) { | ||
| //An error will be shown to the user in the reportPhishing function | ||
| SentryLog.e(TAG, getString(R.string.errorPhishingMessagesNull)) |
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.
The string id mentions that list is "null" but the list is not null, it's empty. Which is also what the string says.
Maybe we can rename this string id
|



No description provided.