Fix meetings tab: correct week navigation, reader UX improvements#32
Open
Boudbois2271 wants to merge 2 commits into
Open
Fix meetings tab: correct week navigation, reader UX improvements#32Boudbois2271 wants to merge 2 commits into
Boudbois2271 wants to merge 2 commits into
Conversation
- Fix MWB month calculation (inverted condition + missing +1 for 1-indexed month) - MWB and Watchtower now fetch TOC and open to current week/article instead of cover or index - Add getCurrentMWBWeek(): parses first week start date, computes week offset from today - Add getCurrentWTArticle(): finds first Sunday of study month, computes article offset - Show week/article title in link text (e.g. 'Life and Ministry — May 18-24') - Show loading state while fetches are in flight - Show offline error with link to /publications.html if publication not cached - Fix missing </div> closing tag in meetings.html - Add hashchange listener in reader.html so sidebar links work while already on reader - Add Back button in reader.html navbar (history.back()) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
getCurrentMWBWeek and getCurrentWTArticle both evaluated the fallback value (items[1] / items[2]) on the line before the length guard, making the guard unreachable in exactly the cases it was meant to protect against. If the TOC had fewer entries than expected, both functions threw TypeError instead of handling the error path. Fix: move the guard above the fallback declaration in both functions. Return null when the TOC is structurally invalid; callers now throw an explicit Error so the existing .catch() handler shows the offline message rather than silently swallowing an unrelated TypeError. Also: unify week-offset rounding. getCurrentWTArticle used Math.round while getCurrentMWBWeek used Math.floor. Week offsets must be floored — a day-count that is 6.9 weeks should not round up to week 7. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
The meetings tab had several bugs that made it mostly non-functional. This PR fixes them and adds a few small UX improvements to the reader.
meethelper.js
MWB month calculation was wrong (inverted condition + off-by-one)
The
% 2 === 0condition was inverted, causing the wrong bimonthly publication to be fetched every other month. Additionally,getMonth()(0-indexed) was used without+1, producing incorrect month codes half the year.MWB link pointed to bare root
The MWB link went to
/reader.html#/api/publications/mwb_YYYYMM/with no chapter, showing a blank page. It now fetches the TOC first (same approach as the Watchtower).Both links always opened to week 1 / the index page
li[1])Both now compute the current week/article from today's date:
getCurrentMWBWeek()— parses the first week's start date from the TOC title (e.g. "May 4-10"), computes the week offset from todaygetCurrentWTArticle()— finds the first Sunday of the study month, computes the article offsetUX improvements
Insight and You Will Find Success")
redirect to /publications.html
meetings.html
</div>closing tag for#page-content-wrapper--- ### reader.html- Added
hashchangelistener so clile, Publications) while already onreader.htmlcorrectly reloads the ng the URL