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.

Settings: a paired phone started offline counts its photos and videos as waiting to upload, not as kept on this device only

Duarte Santos06c76c5ecf36
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index 51b35436c..b888e7874 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -835,7 +835,11 @@ function MediaRow() {
const user = useStore(s => s.user)
const config = useStore(s => s.config)
const status = useSyncExternalStore(subscribeMediaStatus, getMediaStatus)
- const remote = !!(user && config?.media)
+ // Signed in, the files go to the server unless it has said it stores none. A config not known
+ // yet — a phone started without a network; it is not kept between starts — is not that answer:
+ // what is waiting is counted as waiting (and goes up once the server answers), not called
+ // local-only as a guest's files are.
+ const remote = !!user && (config == null || !!config.media)
useEffect(() => { if (remote) syncMedia() }, [remote])
const pending = remote ? pendingRefCount(S) : 0
const u = status.usage
diff --git a/frontend/src/views/Settings.media.test.jsx b/frontend/src/views/Settings.media.test.jsx
index be44368cc..3963ad28c 100644
--- a/frontend/src/views/Settings.media.test.jsx
+++ b/frontend/src/views/Settings.media.test.jsx
@@ -4,6 +4,7 @@ import { createRoot } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import Settings from './Settings.jsx'
import { createMediaStore, memoryBackend, _setMediaStore } from '../lib/media-store.js'
+import { _resetMediaOwed } from '../lib/media-owed.js'
import { readZip, zipStore } from '../lib/zip.js'
import { sha256Hex } from '../lib/sha256.js'
import { jpeg } from '../lib/media-samples.test-util.js'
@@ -105,6 +106,27 @@ describe('Settings — photos and videos', () => {
expect(host.querySelector('input[type="file"][accept=".json,.zip,application/json,application/zip"]')).toBeTruthy()
})
+ // QA, v1.3.9: a paired phone started in airplane mode has no config yet (it is never cached),
+ // and the row called its photos "Kept on this device only" — the guest's sentence — with no
+ // count of what was waiting, while they went up by themselves once it was back online.
+ it('signed in with the server\'s config not known yet (an offline start): waiting to upload, not kept here only', async () => {
+ _resetMediaOwed()
+ await media.put(HASH, new Blob([PHOTO]), { mime: 'image/jpeg', pending: true })
+ mocks.user = { id: 'u1', name: 'Ana' }
+ mocks.config = null
+ mocks.sync = { status: 'offline', offline: true }
+ await mount()
+ expect(row('Photos & videos').textContent).not.toContain('Kept on this device only')
+ expect(row('Photos & videos').textContent).toContain('1 waiting to upload')
+ })
+
+ it('signed in to a server that stores no photos or videos: kept on this device only', async () => {
+ mocks.user = { id: 'u1', name: 'Ana' }
+ mocks.config = { invite_only: false }
+ await mount()
+ expect(row('Photos & videos').textContent).toContain('Kept on this device only')
+ })
+
it('without any, none of that shows', async () => {
mocks.S = { ...stateWithPhoto(), customEx: [] }
await mount()