fix: 🐛 keep dining hall open/closed status live (#501)#748
Closed
wilyan09007 wants to merge 1 commit into
Closed
Conversation
The derived hall status was computed from a selectedDate frozen at app load and a today captured once at store creation, with nothing re-deriving on a timer. Leaving a hall page open across an open->close switch left the status stale (e.g. still Open after the hall closed) until refresh. Add a now clock to the restaurant store that ticks every 30s while a hall page is mounted, and use it as the reference time for the open/close window when viewing today. Other selected days are unaffected. Closes #501
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The dining hall's Open/Closed status was derived from a
selectedDatethat is frozen when the app loads and atodaycaptured once when the restaurant store is created, and nothing re-derived it on a timer. If you left a hall page open across an open→close transition, the status stayed stale (e.g. still showing Open after the hall had actually closed) until you refreshed the page.This adds a live
nowclock to the restaurant store that ticks every 30 seconds while a hall page is mounted, and uses it as the reference time for the open/close window when you're viewing today. Any other selected day keeps comparing against the selected date, so its behavior is unchanged.Changes
useRestaurantStore: add anow: Datefield (plussetNow) to the storeuseHallDerived: compare the open/close window against the livenowwhen the selected day is today (falls back toselectedDatefor any other day, preserving existing behavior)useRestaurantPage: ticknowevery 30s viasetIntervalwhile a hall page is mounted, cleaning up the interval on unmountTesting Instructions
No local setup changes are needed beyond the usual dev environment.
Closes #501