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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
store: a save this device refuses no longer swallows the change
Boris 'B' Kurktchiev8a623c7fd000
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex 05eaeab8c..13da600c2 100644--- a/frontend/src/lib/pt-br-locale.test.js+++ b/frontend/src/lib/pt-br-locale.test.js@@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => {.sort(byCodeUnit)const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')- expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(645)+ expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(646)expect(inherited).toHaveLength(660)// If this fails, review the changed keys and wording before accepting a new hash. From// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --listdiff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex dc0a877ca..be8751c19 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -357,6 +357,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Löscht Plan, Trainings und Körpergewicht auf diesem Gerät. Das kann nicht rückgängig gemacht werden.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Löscht Plan, Trainings und Körpergewicht aus deinem Profil auf diesem Server und auf allen angemeldeten Geräten. Das kann nicht rückgängig gemacht werden.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'Synchronisierung fehlgeschlagen: Der Server hat den Upload als zu groß abgelehnt. Deine Änderungen sind noch nicht auf dem Server angekommen.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'Auf diesem Gerät ist kein Speicher mehr frei: Die Änderung ist nicht auf ihm gespeichert. Angemeldet geht sie trotzdem an den Server.','Delete everything': 'Alles löschen','All data reset': 'Alle Daten zurückgesetzt','Backup exported': 'Backup exportiert',diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 2393a0c16..ff9ea1936 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Elimina tu plan, entrenamientos y peso corporal en este dispositivo. No se puede deshacer.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Elimina tu plan, entrenamientos y peso corporal de tu perfil en este servidor y en todos los dispositivos con sesión iniciada. No se puede deshacer.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'Error de sincronización: el servidor rechazó la subida por ser demasiado grande. Tus cambios no han llegado al servidor.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'A este dispositivo no le queda almacenamiento: el cambio no está guardado en él. Con la sesión iniciada, llega igualmente al servidor.','Delete everything': 'Eliminar todo','All data reset': 'Todos los datos restablecidos','Backup exported': 'Copia exportada',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 15e014795..993b89beb 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Supprime ton plan, tes séances et ton poids corporel sur cet appareil. Irréversible.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Supprime ton plan, tes séances et ton poids corporel de ton profil sur ce serveur et sur tous les appareils connectés. Irréversible.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'Échec de la synchronisation : le serveur a refusé l’envoi, trop volumineux. Tes modifications n’ont pas atteint le serveur.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'Cet appareil n’a plus d’espace de stockage : la modification n’y est pas enregistrée. Connecté, elle part quand même vers le serveur.','Delete everything': 'Tout supprimer','All data reset': 'Toutes les données réinitialisées','Backup exported': 'Sauvegarde exportée',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 95c35c135..80ee1ef33 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'इस डिवाइस पर आपकी योजना, वर्कआउट और वज़न हट जाएँगे। इसे पूर्ववत नहीं किया जा सकता।','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'इस सर्वर पर आपकी प्रोफ़ाइल से और साइन इन किए हुए सभी डिवाइस से आपकी योजना, वर्कआउट और वज़न हट जाएँगे। इसे पूर्ववत नहीं किया जा सकता।','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'सिंक विफल: सर्वर ने अपलोड को बहुत बड़ा बताकर अस्वीकार कर दिया। आपके बदलाव सर्वर तक नहीं पहुँचे हैं।',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'इस डिवाइस में जगह नहीं बची: बदलाव इस पर सेव नहीं हुआ है। साइन इन होने पर यह फिर भी सर्वर तक पहुँच जाएगा।','Delete everything': 'सब हटाएँ','All data reset': 'सारा डेटा रीसेट','Backup exported': 'बैकअप निर्यात हुआ',diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex a1cf236c0..3f9a82eef 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -343,6 +343,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Törli a terved, edzéseid és testsúlyod ezen az eszközön. Ez nem vonható vissza.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Törli a terved, edzéseid és testsúlyod a profilodból ezen a szerveren és minden bejelentkezett eszközön. Ez nem vonható vissza.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'A szinkronizálás nem sikerült: a szerver túl nagynak találta a feltöltést és elutasította. A módosításaid nem jutottak el a szerverre.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'Ezen az eszközön elfogyott a tárhely: a módosítás nincs rajta elmentve. Bejelentkezve így is eljut a kiszolgálóra.','Delete everything': 'Minden törlése','All data reset': 'Minden adat visszaállítva','Backup exported': 'Biztonsági mentés exportálva',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 89d904785..0b2d69b12 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Elimina piano, allenamenti e peso corporeo su questo dispositivo. Irreversibile.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Elimina piano, allenamenti e peso corporeo dal tuo profilo su questo server e su tutti i dispositivi connessi. Irreversibile.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'Sincronizzazione fallita: il server ha rifiutato il caricamento perché troppo grande. Le tue modifiche non hanno raggiunto il server.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'Questo dispositivo non ha più spazio: la modifica non è salvata su di esso. Se hai effettuato l’accesso, arriva comunque al server.','Delete everything': 'Elimina tutto','All data reset': 'Tutti i dati azzerati','Backup exported': 'Backup esportato',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex f36bbe008..34c46fe56 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': '이 기기의 계획, 운동, 체중을 삭제합니다. 되돌릴 수 없어요.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': '이 서버의 프로필과 로그인된 모든 기기에서 계획, 운동, 체중을 삭제합니다. 되돌릴 수 없어요.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': '동기화 실패: 서버가 업로드가 너무 크다며 거부했습니다. 변경 내용이 서버에 반영되지 않았습니다.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': '이 기기에 저장 공간이 없습니다: 변경 내용이 기기에 저장되지 않았습니다. 로그인 상태라면 서버로는 그대로 전송됩니다.','Delete everything': '전부 삭제','All data reset': '모든 데이터 초기화됨','Backup exported': '백업 내보냄',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 529d5ab92..fb9551997 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Usuwa plan, treningi i masę ciała na tym urządzeniu. Nie można tego cofnąć.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Usuwa plan, treningi i masę ciała z profilu na tym serwerze i ze wszystkich zalogowanych urządzeń. Nie można tego cofnąć.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'Synchronizacja nie powiodła się: serwer odrzucił przesyłanie jako zbyt duże. Twoje zmiany nie dotarły na serwer.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'To urządzenie nie ma już miejsca: zmiana nie jest na nim zapisana. Po zalogowaniu trafi jednak na serwer.','Delete everything': 'Usuń wszystko','All data reset': 'Wszystkie dane zresetowane','Backup exported': 'Kopia wyeksportowana',diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 087c69641..3ab28613a 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -127,6 +127,7 @@ export const PT_BR_OVERRIDES = {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Exclui seu plano, seus treinos e seu peso corporal deste dispositivo. Esta ação não pode ser desfeita.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Exclui seu plano, seus treinos e seu peso corporal do seu perfil neste servidor e de todos os dispositivos conectados. Esta ação não pode ser desfeita.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'A sincronização falhou: o servidor recusou o envio por ser grande demais. Suas alterações não chegaram ao servidor.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'Este dispositivo está sem espaço: a alteração não está salva nele. Com a sessão iniciada, ela chega ao servidor de qualquer forma.','Delete everything': 'Excluir tudo','Backup exported': 'Backup exportado','Import backup?': 'Importar backup?',diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex d07541e8d..fc28ddbcf 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Elimina o teu plano, treinos e peso corporal neste dispositivo. Não pode ser anulado.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Elimina o teu plano, treinos e peso corporal do teu perfil neste servidor e em todos os dispositivos com sessão iniciada. Não pode ser anulado.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'A sincronização falhou: o servidor recusou o envio por ser demasiado grande. As tuas alterações não chegaram ao servidor.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'Este dispositivo não tem espaço livre: a alteração não está guardada nele. Com sessão iniciada, chega ainda assim ao servidor.','Delete everything': 'Eliminar tudo','All data reset': 'Todos os dados repostos','Backup exported': 'Cópia exportada',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex accc919de..f8ebf9c8c 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Удаляет план, тренировки и вес тела на этом устройстве. Отменить нельзя.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Удаляет план, тренировки и вес тела из профиля на этом сервере и со всех устройств, где выполнен вход. Отменить нельзя.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'Синхронизация не удалась: сервер отклонил загрузку как слишком большую. Твои изменения не дошли до сервера.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'На этом устройстве нет места: изменение на нём не сохранено. Если вы вошли в аккаунт, оно всё равно уйдёт на сервер.','Delete everything': 'Удалить всё','All data reset': 'Все данные сброшены','Backup exported': 'Копия экспортирована',diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex e8fdc2ff5..002b4f0cd 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -343,6 +343,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'จะลบแผน, การออกกำลังกาย และน้ำหนักตัวบนเครื่องนี้ ไม่สามารถย้อนกลับได้','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'จะลบแผน, การออกกำลังกาย และน้ำหนักตัวออกจากโปรไฟล์ของคุณบนเซิร์ฟเวอร์นี้ และจากทุกอุปกรณ์ที่เข้าสู่ระบบอยู่ ไม่สามารถย้อนกลับได้','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'ซิงค์ไม่สำเร็จ: เซิร์ฟเวอร์ปฏิเสธการอัปโหลดเพราะข้อมูลใหญ่เกินไป การเปลี่ยนแปลงของคุณยังไม่ถึงเซิร์ฟเวอร์',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'อุปกรณ์นี้ไม่มีที่ว่างเหลือ: การเปลี่ยนแปลงไม่ได้บันทึกไว้บนอุปกรณ์ หากลงชื่อเข้าใช้อยู่ ข้อมูลจะยังถูกส่งไปที่เซิร์ฟเวอร์','Delete everything': 'ลบทุกอย่าง','All data reset': 'รีเซ็ตข้อมูลทั้งหมดแล้ว','Backup exported': 'ส่งออกข้อมูลสำรองแล้ว',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 82f934fed..0a13c479c 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Bu cihazdaki planını, antrenmanlarını ve vücut ağırlığını siler. Geri alınamaz.','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': 'Bu sunucudaki profilinden ve oturum açılmış tüm cihazlardan planını, antrenmanlarını ve vücut ağırlığını siler. Geri alınamaz.','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': 'Eşitleme başarısız: sunucu yüklemeyi çok büyük diye reddetti. Değişikliklerin sunucuya ulaşmadı.',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': 'Bu cihazda yer kalmadı: değişiklik cihaza kaydedilmedi. Oturum açıkken sunucuya yine de gidiyor.','Delete everything': 'Her şeyi sil','All data reset': 'Tüm veriler sıfırlandı','Backup exported': 'Yedek dışa aktarıldı',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 7f4492b44..85360be61 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -342,6 +342,7 @@ export default {'Deletes your plan, workouts and body weight on this device. This cannot be undone.': '删除本设备上的计划、训练和体重。无法撤销。','Deletes your plan, workouts and body weight from your profile on this server and on every signed-in device. This cannot be undone.': '从此服务器上的档案以及所有已登录设备中删除计划、训练和体重。无法撤销。','Sync failed: the server refused the upload as too large. Your changes have not reached the server.': '同步失败:服务器拒绝了上传,内容过大。你的更改尚未同步到服务器。',+ 'This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.': '此设备存储空间已满:更改未保存在设备上。已登录时,它仍会同步到服务器。','Delete everything': '全部删除','All data reset': '所有数据已重置','Backup exported': '备份已导出',diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex 00fc90d83..339365131 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -109,6 +109,7 @@ export const useStore = create((set, get) => {let pushTm = nulllet saveTm = nulllet toldTooLarge = false+ let toldNoRoom = false // the save itself was refused — said once per streak, like the abovelet pushing = null // the PUT in flight, so a second push waits for it instead of racing itlet pushAgain = false // a push asked for while one was in flight — run once more after itlet pulling = null // the GET in flight, so two resume signals make one request@@ -145,7 +146,22 @@ export const useStore = create((set, get) => {const persist = (S, push = true, stamp = true) => {if (stamp) S._ts = Date.now()registerCustom(S.customEx)- localStorage.setItem(KEY, JSON.stringify(S))+ // A refused write used to take the change with it — Finish looked like it simply did+ // nothing. The copy is kept in memory either way and marked as owed to the server, so a+ // signed-in device still gets it there; and it is said out loud once, because a change that+ // is not on the device is the one thing the screen cannot show on its own.+ try {+ localStorage.setItem(KEY, JSON.stringify(S))+ toldNoRoom = false+ } catch (e) {+ try { localStorage.setItem('gym_dirty', '1') } catch { /* the same wall */ }+ if (!toldNoRoom) {+ toldNoRoom = true+ import('./useUI.js')+ .then(({ useUI }) => useUI.getState().toast(t('This device is out of storage: the change is not saved on it. Signed in, it still goes to the server.')))+ .catch(() => {})+ }+ }set({ S })if (MOBILE) nativePersist()if (push && get().user) {diff --git a/frontend/src/store/useStore.restore.test.jsx b/frontend/src/store/useStore.restore.test.jsxindex abf28a23d..1748e65e1 100644--- a/frontend/src/store/useStore.restore.test.jsx+++ b/frontend/src/store/useStore.restore.test.jsx@@ -355,3 +355,50 @@ describe('push failures', () => {await vi.waitFor(() => expect(toast).toHaveBeenCalledTimes(2))})})++describe('a save this device refuses', () => {+ // localStorage throwing (a device genuinely full, a private window with next to no quota) used+ // to take the change with it: persist wrote before it told the store, so Finish just did+ // nothing at all and said nothing either.+ const refusingStorage = () => {+ const real = Object.getOwnPropertyDescriptor(globalThis, 'localStorage')+ const store = globalThis.localStorage+ const guard = new Proxy(store, {+ get(target, prop) {+ const value = Reflect.get(target, prop)+ if (prop === 'setItem') return (key, v) => { if (key === 'gym_state_v1') throw new DOMException('quota', 'QuotaExceededError'); return store.setItem(key, v) }+ return typeof value === 'function' ? value.bind(target) : value+ }+ })+ Object.defineProperty(globalThis, 'localStorage', { value: guard, configurable: true })+ return () => Object.defineProperty(globalThis, 'localStorage', real)+ }++ it('keeps the change, marks it owed to the server, and says so once', async () => {+ toast.mockClear()+ useStore.setState({ S: clone(DEF), user: { id: 'user-1' }, ready: true })+ api.mockResolvedValue({})+ const undo = refusingStorage()+ try {+ useStore.getState().update(s => { s.workouts.push(workout('logged-with-no-room')) }, false)+ expect(useStore.getState().S.workouts.map(w => w.id)).toEqual(['logged-with-no-room'])+ expect(localStorage.getItem('gym_dirty')).toBe('1')+ await vi.waitFor(() => expect(toast).toHaveBeenCalledTimes(1))+ expect(toast.mock.calls[0][0]).toMatch(/out of storage/)++ useStore.getState().update(s => { s.restSec = 120 }, false) // still refused — said once+ expect(useStore.getState().S.restSec).toBe(120)+ await new Promise(r => setTimeout(r, 0))+ expect(toast).toHaveBeenCalledTimes(1)+ } finally { undo() }++ // Room again: the next refusal is news once more.+ useStore.getState().update(s => { s.restSec = 90 }, false)+ expect(JSON.parse(localStorage.getItem('gym_state_v1')).restSec).toBe(90)+ const undo2 = refusingStorage()+ try {+ useStore.getState().update(s => { s.restSec = 150 }, false)+ await vi.waitFor(() => expect(toast).toHaveBeenCalledTimes(2))+ } finally { undo2() }+ })+})