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: the full-quota toast gives the space used to one decimal, as the server and Settings do

Duarte Santosecae42efbc54
diff --git a/frontend/src/lib/media-sync.js b/frontend/src/lib/media-sync.js
index 655b374ba..d5c2d64c0 100644
--- a/frontend/src/lib/media-sync.js
+++ b/frontend/src/lib/media-sync.js
@@ -24,7 +24,7 @@ import { sha256Hex } from './sha256.js'
import { mediaStore as sharedStore } from './media-store.js'
import { api, apiBlob, apiUpload } from './api.js'
import { prefetchAllowed } from './media-prefetch.js'
-import { MB, BG_UPLOAD_METERED_MAX_MB, LOCAL_CACHE_MAX_MB, LOCAL_GC_GRACE_MS, limitsFrom } from './media-limits.js'
+import { MB, BG_UPLOAD_METERED_MAX_MB, LOCAL_CACHE_MAX_MB, LOCAL_GC_GRACE_MS, limitsFrom, fmtMB } from './media-limits.js'
import { MOBILE, nativeLoad } from './mobile.js'
import { registerMediaRunner, publishMediaStatus, pendingRefCount, loadPending } from './media-owed.js'
import { t } from './i18n-core.js'
@@ -162,7 +162,7 @@ export function createMediaSync(deps = {}) {
if (code === 'media-quota') {
if (!quotaTold) {
quotaTold = true
- d.toast(t('Your photo and video space on the server is full ({0} of {1} MB).', Math.round(Number(e.data?.usedMB) || 0), Math.round(Number(e.data?.quotaMB) || 0)))
+ d.toast(t('Your photo and video space on the server is full ({0} of {1} MB).', fmtMB(Number(e.data?.usedMB) || 0), fmtMB(Number(e.data?.quotaMB) || 0)))
}
stopped = true
break
diff --git a/frontend/src/lib/media-sync.test.js b/frontend/src/lib/media-sync.test.js
index 1a13efbae..fc5c77a31 100644
--- a/frontend/src/lib/media-sync.test.js
+++ b/frontend/src/lib/media-sync.test.js
@@ -6,6 +6,7 @@ import { sha256Hex } from './sha256.js'
import { _resetMediaOwed, getMediaStatus } from './media-owed.js'
import { jpeg, png } from './media-samples.test-util.js'
import { installedApp, prefetchAllowed } from './media-prefetch.js'
+import { _setLangState } from './i18n-core.js'
const MB = 1024 * 1024
const hex = c => c.repeat(64)
@@ -96,6 +97,21 @@ describe('syncMedia', () => {
expect([...media.pendingNow()]).toEqual([hex('e')])
})
+ // QA, v1.3.9: a 1 MB quota with 60 KB in it read "full (0 of 1 MB)" while Settings said 0.1.
+ it('the full-quota toast gives the space used as the server and Settings do, one decimal in the language\'s own mark', async () => {
+ const S = { customEx: [{ id: 'a', media: refOf(hex('a')) }] }
+ await put(hex('a'))
+ apiUpload.mockRejectedValue(Object.assign(new Error('full'), { status: 413, code: 'media-quota', data: { usedMB: 0.1, quotaMB: 1 } }))
+ await make(appStore({ S })).syncMedia()
+ expect(toast).toHaveBeenCalledWith('Your photo and video space on the server is full (0.1 of 1 MB).')
+ _setLangState('de', { 'Your photo and video space on the server is full ({0} of {1} MB).': 'Voll ({0} von {1} MB).' }, null, null)
+ try {
+ toast.mockClear()
+ await make(appStore({ S })).syncMedia()
+ expect(toast).toHaveBeenCalledWith('Voll (0,1 von 1 MB).')
+ } finally { _setLangState('en', null, null, null) }
+ })
+
it('a network stop waits out its backoff, but the network coming back (a forced run) tries at once', async () => {
const S = { customEx: [{ id: 'a', media: refOf(hex('a')) }] }
await put(hex('a'))