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.

Custom exercises: a guest in the browser on a server that stores no media gets no Add either

Duarte Santos6e614dfeee59
diff --git a/frontend/src/components/CustomMediaField.jsx b/frontend/src/components/CustomMediaField.jsx
index 41b5d2001..835200c49 100644
--- a/frontend/src/components/CustomMediaField.jsx
+++ b/frontend/src/components/CustomMediaField.jsx
@@ -17,6 +17,7 @@ import { useUI } from '../store/useUI.js'
import { t } from '../lib/i18n.js'
import { mediaOf, fmtClip } from '../lib/media-refs.js'
import { mediaStore } from '../lib/media-store.js'
+import { MOBILE } from '../lib/mobile.js'
import { limitsFrom, fmtMB, MB } from '../lib/media-limits.js'
import { CustomThumb } from './CustomMedia.jsx'
import { Row, Button } from './ui.jsx'
@@ -54,8 +55,11 @@ export default function CustomMediaField({ media, url, onChange }) {
const m = mediaOf({ media })
// Signed in to a server that answered without a `media` block: it predates the feature or has
// MEDIA_UPLOADS=0. Nothing would ever reach it. A config not known yet (an offline start) is
- // not that answer — a file picked then waits here and goes up once the server is reached.
- const serverLacks = !!user && !!config && !config.media
+ // not that answer — a file picked then waits here and goes up once the server is reached. A
+ // guest in the browser is on that same server, and what it picks would be owed and never sent
+ // once it signs up; a phone in local mode has no server (a config left from an earlier pairing
+ // says nothing about it).
+ const serverLacks = (!!user || !MOBILE) && !!config && !config.media
const onFile = async ev => {
const file = ev.target.files && ev.target.files[0]
diff --git a/frontend/src/sheets.custom-media.test.jsx b/frontend/src/sheets.custom-media.test.jsx
index 5b2126d68..d67d1ef13 100644
--- a/frontend/src/sheets.custom-media.test.jsx
+++ b/frontend/src/sheets.custom-media.test.jsx
@@ -179,6 +179,15 @@ describe('custom exercise photo, GIF or video, and link', () => {
expect(form.textContent).toContain('Your server does not store photos and videos yet.')
expect([...form.querySelectorAll('button')].some(b => b.textContent.trim() === 'Add')).toBe(false)
expect(form.querySelector('input[type="url"]')).toBeTruthy() // the link still works
+ // A guest in the browser is on that same server: what it picked would never reach it either.
+ act(() => { mounted.splice(0).forEach(root => root.unmount()) })
+ useUI.setState({ sheets: [] })
+ useStore.setState({ user: null, config: { invite_only: false, allow_guest: true } })
+ customExSheet(null)
+ form = renderTop()
+ await settle()
+ expect(form.textContent).toContain('Your server does not store photos and videos yet.')
+ expect([...form.querySelectorAll('button')].some(b => b.textContent.trim() === 'Add')).toBe(false)
})
it('where this browser cannot keep files, Add is there but off, and says why', async () => {