A shared plan file can no longer take the app down
Importing a plan whose exercise ids this build doesn't know — a
hand-edited file, an export from a build with a different dataset — put
those ids straight into a routine. The routine editor skipped them
silently (you could neither see nor delete them), and starting the
routine reached for ex.n on undefined: white screen, no tab bar, no way
back. The running workout is persisted, so it came back on every reload.
Three layers, so this class of bug can't reach the screen again:
· parsePlan() drops ids that resolve to neither the library nor a
custom exercise carried in the same file, and the import sheet says
how many were left out.
· exOr() renders an unresolvable id as a placeholder, so the routine
editor shows it (and lets you remove it) instead of hiding it, and
the workout view survives one.
· an ErrorBoundary around the routes: it keeps the tab bar alive,
offers a reload, and can discard a running workout that can't be
drawn. It is keyed on the route, so switching tabs clears it.
Turning the schedule switch on now really replaces Mon–Sun, as the
switch has always claimed. It only wrote the days the shared plan filled,
so days it left empty kept your own routine and you silently ended up
training a mix of two plans.
Also here, because they sit in the same lines: the tags that carry a unit
or a whole sentence opt out of the capitalise rule ("Best: 85 Kg", "Last
Time You Hit All Reps"), and the workout header's "best" now includes the
working weight you confirmed, so it agrees with the sheet that asked for
it.
This commit is contained in:
1 parent
c8a68e37e1
commit
3d5b00cecd
8 files changed
+126
-36
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { Component } from 'react'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
import Icon from './Icon.jsx'
|
||||
import { Button } from './ui.jsx'
|
||||
|
||||
/**
|
||||
* Last line of defence: one bad render used to blank the whole app, with no way back —
|
||||
* a workout referencing an exercise the build doesn't know would white-screen and, since
|
||||
* the running workout is persisted, do it again on every reload.
|
||||
*
|
||||
* Sits inside #app so the tab bar stays usable; the shell keys this subtree on the route,
|
||||
* so switching tabs re-mounts it and clears the error by itself.
|
||||
*/
|
||||
export default class ErrorBoundary extends Component {
|
||||
constructor(props) { super(props); this.state = { failed: false } }
|
||||
static getDerivedStateFromError() { return { failed: true } }
|
||||
componentDidCatch(err) { console.error('openGym render error:', err) }
|
||||
|
||||
render() {
|
||||
if (!this.state.failed) return this.props.children
|
||||
const active = useStore.getState().S.active
|
||||
return (
|
||||
<div className="narrow">
|
||||
<div className="empty" style={{ marginTop: '18vh' }}>
|
||||
<div className="ico"><Icon name="info" /></div>
|
||||
<div style={{ fontWeight: 600, marginBottom: 6 }}>{t('Something went wrong')}</div>
|
||||
{t('This screen could not be drawn. Your data is safe on this device.')}
|
||||
</div>
|
||||
<Button variant="primary" icon="reset" onClick={() => location.reload()}>{t('Reload openGym')}</Button>
|
||||
{active && <>
|
||||
<div style={{ height: 8 }} />
|
||||
<Button variant="danger" icon="trash" onClick={() => {
|
||||
useStore.getState().update(s => { s.active = null })
|
||||
location.reload()
|
||||
}}>{t('Discard the running workout')}</Button>
|
||||
</>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user