Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Plan rotation: Also on fixed days leaves out routines already in the loop, and days that add nothing

Duarte Santos595a88530f96
diff --git a/frontend/src/views/Home.jsx b/frontend/src/views/Home.jsx
index 56dfd6b89..5eb143a3b 100644
--- a/frontend/src/views/Home.jsx
+++ b/frontend/src/views/Home.jsx
@@ -72,8 +72,8 @@ export default function Home() {
const queue = queueView(S, todayISO())
// This card shows one thing or the other — QueueRow for a live queue, or Rotation chosen with
// nothing built yet (S.scheduleMode), in which case there is no queue for QueueRow to render and
- // an empty-state card takes its place — but that is Home's own layout, not a claim that Plan's
- // weekday grid goes away too: it stays up alongside a live queue there (Plan.jsx, hideGrid).
+ // an empty-state card takes its place. Plan does the same in rotation mode: no weekday grid, only
+ // the days that add a routine the loop does not have (Plan.jsx, "Also on fixed days").
const rotating = scheduleModeOf(S) === 'rotation'
// A planner-written queue (no rotationId) still names its weekday when it hasn't started yet —
// that copy predates rotation and stays as it is. Our own rotation has no weekday of its own
diff --git a/frontend/src/views/Plan.jsx b/frontend/src/views/Plan.jsx
index 035eb223a..2a3276c52 100644
--- a/frontend/src/views/Plan.jsx
+++ b/frontend/src/views/Plan.jsx
@@ -150,8 +150,7 @@ function Schedule({ S, update, nav, mode }) {
const dayRoutines = d => [].concat(S.week[d] || []).map(routineOf).filter(Boolean)
// One weekday: what is on it at a glance, and a tap to change it (dayAssignSheet picks one
// routine, several for a combined day, or a rest day).
- const dayRow = d => {
- const rs = dayRoutines(d)
+ const dayRow = (d, rs = dayRoutines(d)) => {
return <div key={d} className="item plan-day" data-day={d} aria-label={t(DAYN[d])} {...tappable(() => dayAssignSheet(d))}>
<span className={'plan-day-n' + (d === todayDow ? ' today' : '')} aria-hidden="true">{t(DAYS[d])}</span>
<span className={'lrow-i' + (rs.length ? '' : ' rest')}><Icon name={rs.length ? glyphOf(rs[0].emoji) : 'moon'} /></span>
@@ -162,7 +161,10 @@ function Schedule({ S, update, nav, mode }) {
<Icon name="chevronRight" className="chev" />
</div>
}
- const plannedDays = weekOrder(ws).filter(d => dayRoutines(d).length)
+ // Beside a loop, a weekday shows only what it adds to it: a routine that is in the loop already
+ // is the loop's session, the same rule Home follows (effectiveRoutineIds, history.js).
+ const extraRoutines = d => dayRoutines(d).filter(r => !seq.includes(r.id))
+ const plannedDays = weekOrder(ws).filter(d => extraRoutines(d).length)
const doneCount = qv ? qv.items.filter(i => i.state === 'done').length : 0
const stateWord = item => item.state === 'pinned' ? fmtDate(item.on, true)
: { done: t('Done'), next: t('Up next'), later: t('Later') }[item.state]
@@ -197,7 +199,7 @@ function Schedule({ S, update, nav, mode }) {
{mode === 'week' ? <>
<h4 className="sec">{t('This week')}</h4>
- <div className="list plan-week">{weekOrder(ws).map(dayRow)}</div>
+ <div className="list plan-week">{weekOrder(ws).map(d => dayRow(d))}</div>
<p className="sect-f">{t('Want two routines on one day? Tap the day and pick both.')}</p>
</> : <div className="rotation">
<div className="row between plan-sec-h">
@@ -243,10 +245,11 @@ function Schedule({ S, update, nav, mode }) {
onClick={() => update(s => startPass(s))}>{t('Start the loop')}</Button>}
</div>
{/* The weekday routines ride along beside a loop (effectiveRoutineIds, history.js) and feed
- the same tally (weekTally, queue.js), so the days that still hold one stay in sight. */}
+ the same tally (weekTally, queue.js), so the days that still add one stay in sight; a
+ day whose only routines are in the loop already adds nothing and is left out. */}
{plannedDays.length > 0 && <>
<h4 className="sec">{t('Also on fixed days')}</h4>
- <div className="list plan-week">{plannedDays.map(dayRow)}</div>
+ <div className="list plan-week">{plannedDays.map(d => dayRow(d, extraRoutines(d)))}</div>
<p className="sect-f">{t('These count on top of the loop. Tap a day to change or clear it.')}</p>
</>}
</div>}
diff --git a/frontend/src/views/Plan.rotation.test.jsx b/frontend/src/views/Plan.rotation.test.jsx
index a5e3ff758..f39d1182b 100644
--- a/frontend/src/views/Plan.rotation.test.jsx
+++ b/frontend/src/views/Plan.rotation.test.jsx
@@ -135,6 +135,17 @@ describe('Plan — the loop', () => {
expect(host.querySelectorAll('.plan-day').length).toBe(1)
})
+ it('a weekday shows only what the loop does not have, and a day with nothing else is left out', () => {
+ mount({ queue: live({ rotationId: 'r1' }), rotation: saved, week: { 1: ['a', 'c'], 3: ['b'], 5: ['a'] } })
+ expect(headings()).toContain('Also on fixed days')
+ expect([...host.querySelectorAll('.plan-day')].map(d => d.dataset.day)).toEqual(['1'])
+ expect(host.querySelector('.plan-day[data-day="1"] .tt').textContent).toBe('C')
+ remount()
+ mount({ queue: live({ rotationId: 'r1' }), rotation: saved, week: { 3: ['b'], 5: ['a'] } })
+ expect(headings()).not.toContain('Also on fixed days')
+ expect(host.querySelectorAll('.plan-day').length).toBe(0)
+ })
+
it('a session done this round reads Done and moves Up next along', () => {
const since = Date.now() - 86400000
mount({