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

Display "Current Interval" on the 'Set Due Date' dialog #18028

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

theMr17
Copy link
Contributor

@theMr17 theMr17 commented Feb 26, 2025

Purpose / Description

This PR enhances the 'Set Due Date' dialog by displaying the "Current Interval" when a single card is selected. This provides users with better context on the existing interval before setting a new due date. If multiple cards are selected, the interval is hidden, as displaying it would not be meaningful in that scenario.

Fixes

Approach

Adds a display of the current interval to the "Set Due Date" dialog when a single card is selected. If multiple cards are selected, the interval is hidden as it would not be meaningful.

How Has This Been Tested?

Single date selection (single card) Ranged date selection (single card) Single date selection (multiple cards)
image image image

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Contributor

Important

Maintainers: This PR contains Strings changes

  1. Sync Translations before merging this PR and wait for the action to complete
  2. Review and merge the auto-generated PR in order to sync all user-submitted translations
  3. Sync Translations again and merge the PR so the huge automated string changes caused by merging this PR are by themselves and easy to review

findViewById<MaterialTextView>(R.id.current_interval_text)!!.also {
// Current interval cannot be shown if multiple cards are selected
if (viewModel.cardCount == 1) {
val currentCard = getColUnsafe().getCard(cardIds[0])
Copy link
Member

Choose a reason for hiding this comment

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

Try using withCol { isntead of getColUnsafe. You'll find some examples if you search around the repository

Copy link
Member

Choose a reason for hiding this comment

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

Also, getting the interval should be in the viewModel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @BrayanDSO updated with withCol and moved the fetching of interval to viewmodel.

@BrayanDSO BrayanDSO added the Needs Author Reply Waiting for a reply from the original author label Feb 28, 2025
@theMr17
Copy link
Contributor Author

theMr17 commented Mar 8, 2025

Hey @BrayanDSO and @ShridharGoel, thanks for the reviews! I've addressed your comments--please take a look.

@ShridharGoel ShridharGoel added Needs Second Approval Has one approval, one more approval to merge and removed Needs Author Reply Waiting for a reply from the original author labels Mar 8, 2025
Copy link
Member

@Arthur-Milchior Arthur-Milchior left a comment

Choose a reason for hiding this comment

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

I'd appreciate if you could ensure it all fits in a single commit, and have the commit message we want in the history.
Also a small change in documentation, and all is good.

I'd appreciate some tests too. We already have unit tests for SetDueDate dialog and view model, so it should hopefully be little extra work.

@@ -112,12 +114,31 @@ class SetDueDateViewModel : ViewModel() {
field = value
}

val currentInterval = MutableStateFlow<Int?>(null)
Copy link
Member

Choose a reason for hiding this comment

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

Please add some documentation. In particular, stating that the value is the number of day, and that:

  • the value is not-null if exactly one card is selected, which is the only case in which the view should display the interval

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

One issue with non review cards

This code is exceptionally clean, thank you!

}
}
} else {
currentInterval.value = null
Copy link
Member

Choose a reason for hiding this comment

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

If there's a need to set this to null, comment it. If not, remove it

* The value is not-null if exactly one card is selected, which is the only case
* in which the view should display the interval.
*/
val currentInterval = MutableStateFlow<Int?>(null)
Copy link
Member

Choose a reason for hiding this comment

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

You can optionally typealias or use a value class for documentation within the type system

viewModelScope.launch {
withCol {
getCard(cardIds.first()).let {
currentInterval.value = it.ivl
Copy link
Member

Choose a reason for hiding this comment

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

This should only be set if the card is in the review state

A learning/relearning/new card has the value 0 shown here

@lukstbit lukstbit added the squash-merge Squash & force push by author/maintainers requested label Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Second Approval Has one approval, one more approval to merge squash-merge Squash & force push by author/maintainers requested Strings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] Display "current interval" on the 'Set Due Date' dialog
6 participants