Implemented revert to PreMeal After Timeout #49
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe this pull request. Link to relevant GitHub issues, if any.
In service of #23 .
The way the app currently works, if the user ends a meal and is on the PostMeal page (or any other page they decide to stop eating on), the app will re-load into that page when they start another meal. That adds some number of additional clicks the user will have to do before starting the next meal.
Therefore, this PR changes it so that every time the
mealState
is updated, the app stores the timestamp of that update in global state. Then, whenever the app is re-loaded, if more than one hour (3,600,000 ms) have elapsed since the last state transition, it automatically resets the state toU_PreMeal
.Re. user flow considerations, the only possible negative user flow I can think of is where the user pauses the meal for over an hour and refreshes the page upon returning, but actually just wanted to continue with the meal from where they left off. However, at that point the 1 hour break is such a significant break anyway that I also think users' wouldn't mind it too much if they have to start afresh. Particularly since we won't force them to re-acquire a bite (e.g., if the fork already has food), as addressed in #41
Explain how this pull request was tested, including but not limited to the below checkmarks.
Modified
TIME_TO_RESET_MS
to 60,000 (1 min) and verified the following:PreMeal
.PreMeal
. (Note that I tested this by adding a dummy localState variable toBiteSelection
)PreMeal
.PreMeal
. (But note that this does not reset themealStateTransitionTime
, so refreshing after 1 min after the transition will still reset toPreMeal
even if it is less than 1 min after the refresh)With
TIME_TO_RESET_MS
at it's default value of 3,600,000 (1 hour), I verified the following:PreMeal
.BiteSelection
)Before creating a pull request
npm run format
python3 -m black .
in the top-level of this repositoryBefore merging a pull request
Squash and Merge
)