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

Implemented revert to PreMeal After Timeout #49

Merged
merged 4 commits into from
May 11, 2023

Conversation

amalnanavati
Copy link
Contributor

@amalnanavati amalnanavati commented May 10, 2023

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 to U_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:

  • All state changes work as expected.
  • If, after 1 min on the current state, we change to another state, the app does not revert to PreMeal.
  • If, after 1 min on the current state, we re-render the component (e.g., a local state variable changes), the app does not revert to PreMeal. (Note that I tested this by adding a dummy localState variable to BiteSelection)
  • If, after 1 min on the current state, we refresh the page, the app does revert to PreMeal.
  • If, after less than 1 min on the current state, we we refresh the page, the app does not revert to PreMeal. (But note that this does not reset the mealStateTransitionTime, so refreshing after 1 min after the transition will still reset to PreMeal 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:

  • After closing the app on some state and re-opening it less than 1 hour later, the state stays the same.
  • After closing the app on some state and re-opening it 1 hour later, the state reverts to PreMeal.
  • After keeping the app on some state for 1 hour and then pressing a button to change the state, the app changes the state as expected by the button.
  • After keeping the app on some state for 1 hour and then re-rendering the component (e.g., a local state variable changes), the app does not revert to PreMeal. (Note that I tested this by adding a dummy localState variable to BiteSelection)

Before creating a pull request

  • Format React code with npm run format
  • [N/A] Format Python code by running python3 -m black . in the top-level of this repository
  • Thoroughly test your code's functionality, including unintended uses.
  • [N/A] Thoroughly test your code's responsiveness by rendering it on different devices, browsers, etc.
  • Consider the user flow between states that this feature introduces, consider different situations that might occur for the user, and ensure that there is no way for the user to get stuck in a loop.

Before merging a pull request

  • Squash all your commits into one (or Squash and Merge)

Reverts if the app re-render after 1 hour of no state change
@amalnanavati amalnanavati linked an issue May 10, 2023 that may be closed by this pull request
feedingwebapp/src/Pages/Home/Home.jsx Outdated Show resolved Hide resolved
feedingwebapp/src/Pages/Constants.js Outdated Show resolved Hide resolved
@amalnanavati amalnanavati merged commit 1c65b25 into main May 11, 2023
@amalnanavati amalnanavati deleted the amaln/revert_to_pre_meal branch May 11, 2023 06:09
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.

Move from PostMeal to PreMeal for New Meals
2 participants