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 Review Order options #85

Merged
merged 9 commits into from
Dec 23, 2021
Merged

Conversation

rafascar
Copy link

@rafascar rafascar commented Jul 9, 2021

This PR adds a Review Order option on the settings menu to choose the order you want to do your reviews.
It will sort the review queue based on the user's preference before grouping it to respect the Meaning First and Back to Back options.

Implemented Review Orders are:

  • Random Order [default]
  • Lowest Level First
  • Current Level First
  • Ascending SRS Stage
  • Descending SRS Stage

This is what it looks like on iOS 👇

image

This implements some of the suggestions from Issue #72 .

@rafascar rafascar mentioned this pull request Jul 9, 2021
Copy link
Owner

@oguzgelal oguzgelal left a comment

Choose a reason for hiding this comment

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

@rafascar Amazing work 🎉 Thank you so much for the contribution! I quickly reviewed the PR and left a few small comments. Also one more request, any chance we could style the picker component for the web a little bit 😅 I think removing the borders and handling the padding should suffice.

Screenshot 2021-07-10 at 15 22 02

const newQueue = queue.slice();
let currentIndex = 0;

// sort new queue based on the selected review order
Copy link
Owner

Choose a reason for hiding this comment

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

Can we add a DEFAULT option (selected by default) that doesn't apply any sorting at all?

Copy link
Author

Choose a reason for hiding this comment

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

That was kinda my intention with the RANDOM option here, since it is how it works today -- albeit unintentionally.

I'm afraid that if we add a DEFAULT option that doesn't apply any sorting at all, the queue would inherit the last selected option. For example, if a user switches to LOWEST_LEVEL_FIRST and then back to the DEFAULT option, since the DEFAULT does nothing, the queue would still be sorted in the LOWEST_LEVEL_FIRST order. However if we keep the RANDOM as the default selection, we will keep the default, current behavior, although with an extra step.

Does that make sense?

newQueue.sort((a, b) => b.subjectLevel - a.subjectLevel);
break;
case ASCENDING_SRS_STAGE:
newQueue.sort((a, b) => a.review.data.srs_stage - b.review.data.srs_stage);
Copy link
Owner

Choose a reason for hiding this comment

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

I'm a little concerned that if a.review or a.review.data was undefined / null the app would crash. I wonder if there's a chance for that to happen 🤔 Maybe we could take a defensive approach here and use lodash get method for this, maybe something like:

newQueue.sort((a, b) => _.get(a, 'review.data.srs_stage') - _.get(b, 'review.data.srs_stage'));

Copy link
Author

@rafascar rafascar Jul 10, 2021

Choose a reason for hiding this comment

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

Since you mentioned loadsh for the shuffling, browsing through the documentation I found the _.orderBy function that fits like a glove here, so I refactored this part to use lodash for all the Review Order implementations.

@rafascar
Copy link
Author

rafascar commented Jul 10, 2021

Also one more request, any chance we could style the picker component for the web a little bit 😅 I think removing the borders and handling the padding should suffice.

For sure, I'll flex all my front end skills to (try to) make this look prettier 💅

Just one question though, I see that your screenshot is already way nicer than it appears on my PC. 👇

image

I tried to open with all browsers I had installed (Firefox, Chrome and Safari), toggle the Dark Mode button, and even in production (juken.io) it looks like this on my end. Any chance you know what's happening here?

Edit: Saw #86 and figured it was inheriting the Dark Mode from my system preferences -- turned it off and now it is the same as your screenshot!


image

This is what it looks like right now -- @oguzgelal whatchu think?

Copy link
Owner

@oguzgelal oguzgelal left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@oguzgelal oguzgelal merged commit 4b9b9ef into oguzgelal:master Dec 23, 2021
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