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
Sign-in: a plan built while signed out is asked about, kept with Add them, and kept aside otherwise
Duarte Santos8125da7ff3eb
diff --git a/frontend/src/lib/sync-merge.js b/frontend/src/lib/sync-merge.jsindex 4e4f79301..fa2ebf6e2 100644--- a/frontend/src/lib/sync-merge.js+++ b/frontend/src/lib/sync-merge.js@@ -858,9 +858,20 @@ export function localExtras(local, server) {const from = unitOf(local), to = unitOf(server)const differs = (mine, theirs) =>(Number(mine.t) || 0) > (Number(theirs.t) || 0) && Number(convertBodyWeight(mine.w, from, to)) !== Number(theirs.w)+ // Routines, and the rest of what a device sets up (plan days, exercise notes, gym cards,+ // equipment profiles), count too: a guest who only built a plan was never asked, and signing in+ // dropped it. Present only when there are any.+ const ids = f => new Set(list(server?.[f]).map(x => x?.id))+ const routines = list(local?.routines).filter(r => r && r.id != null && !ids('routines').has(r.id)).length+ const keysNew = f => Object.entries(isMap(local?.[f]) ? local[f] : {})+ .filter(([k, v]) => v != null && !(Array.isArray(v) && !v.length) && !(isMap(server?.[f]) && k in server[f])).length+ const setup = ['gymCards', 'equipProfiles'].reduce((n, f) => n + list(local?.[f]).filter(x => x && x.id != null && !ids(f).has(x.id)).length, 0) ++ keysNew('week') + keysNew('dayPlan') + keysNew('exNotes')return {workouts: list(local?.workouts).filter(w => !have.has(workoutKey(w))).length,bodyweight: list(local?.bodyweight).filter(e => e && e.d != null && (!days.has(e.d) || differs(e, days.get(e.d)))).length,- customEx: list(local?.customEx).filter(e => e && !ex.has(e.id)).length+ customEx: list(local?.customEx).filter(e => e && !ex.has(e.id)).length,+ ...(routines ? { routines } : {}),+ ...(setup ? { setup } : {}),}}diff --git a/frontend/src/lib/sync-merge.test.js b/frontend/src/lib/sync-merge.test.jsindex 52b07c0a3..118a7c889 100644--- a/frontend/src/lib/sync-merge.test.js+++ b/frontend/src/lib/sync-merge.test.js@@ -238,7 +238,8 @@ describe('sign-in adoption helpers', () => {it('localExtras counts what the device has that the server does not', () => {// the new day, and 09-01: the device's weigh-in of a day the server has too, entered later// and different (79 kg is 174.2 lb, not the server's 80 lb)- expect(localExtras(local, server)).toEqual({ workouts: 1, bodyweight: 2, customEx: 1 })+ // and the routine and plan day the device made (a guest who only built a plan is asked too)+ expect(localExtras(local, server)).toEqual({ workouts: 1, bodyweight: 2, customEx: 1, routines: 1, setup: 1 })expect(localExtras(server, server)).toEqual({ workouts: 0, bodyweight: 0, customEx: 0 })expect(localExtras(null, server)).toEqual({ workouts: 0, bodyweight: 0, customEx: 0 })})diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 68200631f..1f720583b 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -1982,4 +1982,9 @@ export default {'Options: copy, remove': 'خيارات: نسخ، إزالة','Another device synced while you were importing, so its changes were kept next to the backup.': 'زامن جهاز آخر أثناء الاستيراد، فاحتفظنا بتغييراته إلى جانب النسخة الاحتياطية.','Save as a backup file': 'حفظ كملف نسخة احتياطية',+ 'Add this device\'s plan to your profile?': 'إضافة خطة هذا الجهاز إلى ملفك؟',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'أُعدّت خطتك أو ملاحظاتك أو بطاقات النادي على هذا الجهاز أثناء تسجيل الخروج. أضفها إلى ملفك، أو أبقِ الملف كما هو على الخادم.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': 'أُنشئ {0} روتين على هذا الجهاز أثناء تسجيل الخروج. أضفه إلى ملفك، أو أبقِ الملف كما هو على الخادم.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'أُنشئت {0} روتينات على هذا الجهاز أثناء تسجيل الخروج. أضفها إلى ملفك، أو أبقِ الملف كما هو على الخادم.',+ 'This device, before signing in': 'هذا الجهاز قبل تسجيل الدخول',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 9b6ff4dcb..e07275e70 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1949,4 +1949,9 @@ export default {'Options: copy, remove': 'Optionen: kopieren, entfernen','Another device synced while you were importing, so its changes were kept next to the backup.': 'Ein anderes Gerät hat während des Imports synchronisiert, seine Änderungen bleiben neben dem Backup erhalten.','Save as a backup file': 'Als Backup-Datei sichern',+ 'Add this device\'s plan to your profile?': 'Plan von diesem Gerät zum Profil hinzufügen?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Plan, Notizen oder Studiokarten auf diesem Gerät wurden ohne Anmeldung angelegt. Zum Profil hinzufügen oder das Profil genau so lassen, wie es auf dem Server ist.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} Routine wurde auf diesem Gerät ohne Anmeldung erstellt. Zum Profil hinzufügen oder das Profil genau so lassen, wie es auf dem Server ist.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} Routinen wurden auf diesem Gerät ohne Anmeldung erstellt. Zum Profil hinzufügen oder das Profil genau so lassen, wie es auf dem Server ist.',+ 'This device, before signing in': 'Dieses Gerät, vor der Anmeldung',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 946f6c35e..b2cb1fe81 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': 'Opciones: copiar, quitar','Another device synced while you were importing, so its changes were kept next to the backup.': 'Otro dispositivo se sincronizó mientras importabas, así que sus cambios se quedan junto a la copia.','Save as a backup file': 'Guardar como archivo de copia',+ 'Add this device\'s plan to your profile?': '¿Añadir el plan de este dispositivo a tu perfil?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Tu plan, notas o tarjetas del gimnasio en este dispositivo se crearon sin iniciar sesión. Añádelos a tu perfil o deja el perfil exactamente como está en el servidor.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} rutina se creó en este dispositivo sin iniciar sesión. Añádela a tu perfil o deja el perfil exactamente como está en el servidor.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} rutinas se crearon en este dispositivo sin iniciar sesión. Añádelas a tu perfil o deja el perfil exactamente como está en el servidor.',+ 'This device, before signing in': 'Este dispositivo, antes de iniciar sesión',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex c98927ba6..a5dee25b5 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': 'Options : copier, supprimer','Another device synced while you were importing, so its changes were kept next to the backup.': 'Un autre appareil a synchronisé pendant l’import, ses changements sont gardés à côté de la sauvegarde.','Save as a backup file': 'Enregistrer comme fichier de sauvegarde',+ 'Add this device\'s plan to your profile?': 'Ajouter le programme de cet appareil à votre profil ?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Votre programme, vos notes ou vos cartes de salle sur cet appareil ont été créés sans connexion. Ajoutez-les à votre profil ou gardez le profil exactement tel qu’il est sur le serveur.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} routine a été créée sur cet appareil sans connexion. Ajoutez-la à votre profil ou gardez le profil exactement tel qu’il est sur le serveur.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} routines ont été créées sur cet appareil sans connexion. Ajoutez-les à votre profil ou gardez le profil exactement tel qu’il est sur le serveur.',+ 'This device, before signing in': 'Cet appareil, avant la connexion',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 011b33307..a7d3fa565 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': 'विकल्प: कॉपी, हटाएँ','Another device synced while you were importing, so its changes were kept next to the backup.': 'आयात के दौरान किसी दूसरे डिवाइस ने सिंक किया, इसलिए उसके बदलाव बैकअप के साथ रखे गए।','Save as a backup file': 'बैकअप फ़ाइल के रूप में सहेजें',+ 'Add this device\'s plan to your profile?': 'इस डिवाइस का प्लान अपनी प्रोफ़ाइल में जोड़ें?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'इस डिवाइस पर आपका प्लान, नोट्स या जिम कार्ड बिना साइन इन किए बनाए गए। इन्हें अपनी प्रोफ़ाइल में जोड़ें, या प्रोफ़ाइल को ठीक वैसा ही रखें जैसा सर्वर पर है।',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} रूटीन इस डिवाइस पर बिना साइन इन किए बनाया गया। इसे अपनी प्रोफ़ाइल में जोड़ें, या प्रोफ़ाइल को ठीक वैसा ही रखें जैसा सर्वर पर है।',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} रूटीन इस डिवाइस पर बिना साइन इन किए बनाए गए। इन्हें अपनी प्रोफ़ाइल में जोड़ें, या प्रोफ़ाइल को ठीक वैसा ही रखें जैसा सर्वर पर है।',+ 'This device, before signing in': 'यह डिवाइस, साइन इन से पहले',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex a097a42c9..ddd204f35 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1932,4 +1932,9 @@ export default {'Options: copy, remove': 'Lehetőségek: másolás, eltávolítás','Another device synced while you were importing, so its changes were kept next to the backup.': 'Egy másik eszköz szinkronizált importálás közben, így a változásai megmaradtak a mentés mellett.','Save as a backup file': 'Mentés biztonsági fájlként',+ 'Add this device\'s plan to your profile?': 'Hozzáadod az eszközön lévő tervet a profilodhoz?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Az eszközön lévő terved, jegyzeteid vagy kártyáid bejelentkezés nélkül készültek. Add hozzá őket a profilodhoz, vagy hagyd a profilt pontosan úgy, ahogy a szerveren van.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} rutin készült ezen az eszközön bejelentkezés nélkül. Add hozzá a profilodhoz, vagy hagyd a profilt pontosan úgy, ahogy a szerveren van.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} rutin készült ezen az eszközön bejelentkezés nélkül. Add hozzá őket a profilodhoz, vagy hagyd a profilt pontosan úgy, ahogy a szerveren van.',+ 'This device, before signing in': 'Ez az eszköz, bejelentkezés előtt',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 2f55f8d6c..fcfdc0238 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': 'Opzioni: copia, rimuovi','Another device synced while you were importing, so its changes were kept next to the backup.': 'Un altro dispositivo ha sincronizzato durante l’importazione, quindi le sue modifiche restano accanto al backup.','Save as a backup file': 'Salva come file di backup',+ 'Add this device\'s plan to your profile?': 'Aggiungere il piano di questo dispositivo al tuo profilo?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Il piano, le note o le tessere della palestra su questo dispositivo sono stati creati senza accesso. Aggiungili al tuo profilo o lascia il profilo esattamente com’è sul server.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} routine è stata creata su questo dispositivo senza accesso. Aggiungila al tuo profilo o lascia il profilo esattamente com’è sul server.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} routine sono state create su questo dispositivo senza accesso. Aggiungile al tuo profilo o lascia il profilo esattamente com’è sul server.',+ 'This device, before signing in': 'Questo dispositivo, prima dell’accesso',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 9558cc2cf..a9e617091 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': '옵션: 복사, 삭제','Another device synced while you were importing, so its changes were kept next to the backup.': '가져오는 동안 다른 기기가 동기화해서, 그 변경 사항도 백업과 함께 남겨 뒀어요.','Save as a backup file': '백업 파일로 저장',+ 'Add this device\'s plan to your profile?': '이 기기의 계획을 프로필에 추가할까요?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '로그인하지 않은 상태에서 이 기기에 계획, 메모 또는 헬스장 카드가 만들어졌습니다. 프로필에 추가하거나 서버에 있는 프로필을 그대로 유지하세요.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '로그인하지 않은 상태에서 이 기기에 루틴 {0}개가 만들어졌습니다. 프로필에 추가하거나 서버에 있는 프로필을 그대로 유지하세요.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '로그인하지 않은 상태에서 이 기기에 루틴 {0}개가 만들어졌습니다. 프로필에 추가하거나 서버에 있는 프로필을 그대로 유지하세요.',+ 'This device, before signing in': '로그인 전의 이 기기',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 193e90c95..bfce601c4 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': 'Opcje: kopiuj, usuń','Another device synced while you were importing, so its changes were kept next to the backup.': 'Inne urządzenie zsynchronizowało się podczas importu, więc jego zmiany zostały obok kopii.','Save as a backup file': 'Zapisz jako plik kopii',+ 'Add this device\'s plan to your profile?': 'Dodać plan z tego urządzenia do profilu?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Plan, notatki lub karty siłowni na tym urządzeniu powstały bez logowania. Dodaj je do profilu albo zostaw profil dokładnie taki, jaki jest na serwerze.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} rutyna powstała na tym urządzeniu bez logowania. Dodaj ją do profilu albo zostaw profil dokładnie taki, jaki jest na serwerze.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} rutyn powstało na tym urządzeniu bez logowania. Dodaj je do profilu albo zostaw profil dokładnie taki, jaki jest na serwerze.',+ 'This device, before signing in': 'To urządzenie, przed zalogowaniem',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 29fac1e1b..189557bdf 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1194,6 +1194,11 @@ export const PT_BR_OVERRIDES = {'Left deletes, right copies': 'Esquerda exclui, direita copia','Another device synced while you were importing, so its changes were kept next to the backup.': 'Outro dispositivo sincronizou durante a importação, então as alterações dele ficaram junto com o backup.','Save as a backup file': 'Salvar como arquivo de backup',+ 'Add this device\'s plan to your profile?': 'Adicionar o plano deste dispositivo ao seu perfil?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Seu plano, notas ou cartões da academia neste dispositivo foram criados sem login. Adicione-os ao seu perfil ou mantenha o perfil exatamente como está no servidor.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} rotina foi criada neste dispositivo sem login. Adicione-a ao seu perfil ou mantenha o perfil exatamente como está no servidor.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} rotinas foram criadas neste dispositivo sem login. Adicione-as ao seu perfil ou mantenha o perfil exatamente como está no servidor.',+ 'This device, before signing in': 'Este dispositivo, antes do login',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 03b1e9c06..6c08bb11b 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': 'Opções: copiar, remover','Another device synced while you were importing, so its changes were kept next to the backup.': 'Outro dispositivo sincronizou durante a importação, por isso as alterações dele ficaram junto à cópia.','Save as a backup file': 'Guardar como ficheiro de cópia',+ 'Add this device\'s plan to your profile?': 'Adicionar o plano deste dispositivo ao teu perfil?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'O teu plano, notas ou cartões do ginásio neste dispositivo foram criados sem sessão iniciada. Adiciona-os ao teu perfil ou mantém o perfil exatamente como está no servidor.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} rotina foi criada neste dispositivo sem sessão iniciada. Adiciona-a ao teu perfil ou mantém o perfil exatamente como está no servidor.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} rotinas foram criadas neste dispositivo sem sessão iniciada. Adiciona-as ao teu perfil ou mantém o perfil exatamente como está no servidor.',+ 'This device, before signing in': 'Este dispositivo, antes de iniciar sessão',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 4fbc44491..70eebec16 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1933,4 +1933,9 @@ export default {'Options: copy, remove': 'Действия: копировать, удалить','Another device synced while you were importing, so its changes were kept next to the backup.': 'Другое устройство синхронизировалось во время импорта, поэтому его изменения сохранены рядом с копией.','Save as a backup file': 'Сохранить как файл копии',+ 'Add this device\'s plan to your profile?': 'Добавить план с этого устройства в профиль?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'План, заметки или карты зала на этом устройстве созданы без входа. Добавьте их в профиль или оставьте профиль ровно таким, как на сервере.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '{0} программа создана на этом устройстве без входа. Добавьте её в профиль или оставьте профиль ровно таким, как на сервере.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '{0} программ создано на этом устройстве без входа. Добавьте их в профиль или оставьте профиль ровно таким, как на сервере.',+ 'This device, before signing in': 'Это устройство, до входа',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 29c7d4290..d76709850 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1940,4 +1940,9 @@ export default {'Options: copy, remove': 'ตัวเลือก: คัดลอก, ลบ','Another device synced while you were importing, so its changes were kept next to the backup.': 'อุปกรณ์อื่นซิงก์ระหว่างที่คุณนำเข้า เลยเก็บการเปลี่ยนแปลงของมันไว้คู่กับข้อมูลสำรอง','Save as a backup file': 'บันทึกเป็นไฟล์สำรอง',+ 'Add this device\'s plan to your profile?': 'เพิ่มแผนจากอุปกรณ์นี้ลงในโปรไฟล์ของคุณหรือไม่',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'แผน โน้ต หรือบัตรยิมบนอุปกรณ์นี้ถูกสร้างขณะไม่ได้ลงชื่อเข้าใช้ เพิ่มลงในโปรไฟล์ของคุณ หรือคงโปรไฟล์ไว้ตามที่อยู่บนเซิร์ฟเวอร์',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': 'มีการสร้างรูทีน {0} รายการบนอุปกรณ์นี้ขณะไม่ได้ลงชื่อเข้าใช้ เพิ่มลงในโปรไฟล์ของคุณ หรือคงโปรไฟล์ไว้ตามที่อยู่บนเซิร์ฟเวอร์',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'มีการสร้างรูทีน {0} รายการบนอุปกรณ์นี้ขณะไม่ได้ลงชื่อเข้าใช้ เพิ่มลงในโปรไฟล์ของคุณ หรือคงโปรไฟล์ไว้ตามที่อยู่บนเซิร์ฟเวอร์',+ 'This device, before signing in': 'อุปกรณ์นี้ ก่อนลงชื่อเข้าใช้',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 8e8054ef3..1041c89c9 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': 'Seçenekler: kopyala, kaldır','Another device synced while you were importing, so its changes were kept next to the backup.': 'İçe aktarırken başka bir cihaz eşitlendi, onun değişiklikleri de yedeğin yanında tutuldu.','Save as a backup file': 'Yedek dosyası olarak kaydet',+ 'Add this device\'s plan to your profile?': 'Bu cihazdaki plan profiline eklensin mi?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Bu cihazdaki planın, notların veya salon kartların oturum açılmadan oluşturuldu. Bunları profiline ekle ya da profili sunucudaki hâliyle bırak.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': 'Bu cihazda oturum açılmadan {0} rutin oluşturuldu. Onu profiline ekle ya da profili sunucudaki hâliyle bırak.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'Bu cihazda oturum açılmadan {0} rutin oluşturuldu. Bunları profiline ekle ya da profili sunucudaki hâliyle bırak.',+ 'This device, before signing in': 'Bu cihaz, oturum açmadan önce',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 2104837ec..25d550390 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -1926,4 +1926,9 @@ export default {'Options: copy, remove': 'Дії: копіювати, видалити','Another device synced while you were importing, so its changes were kept next to the backup.': 'Інший пристрій синхронізувався під час імпорту, тож його зміни збережено поруч із копією.','Save as a backup file': 'Зберегти як файл копії',+ 'Add this device\'s plan to your profile?': 'Додати план із цього пристрою в профіль?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'План, нотатки чи картки залу на цьому пристрої створено без входу. Додай їх у профіль або лиши профіль точно таким, як на сервері.',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': 'На цьому пристрої без входу створено програм: {0}. Додай її в профіль або лиши профіль точно таким, як на сервері.',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': 'На цьому пристрої без входу створено програм: {0}. Додай їх у профіль або лиши профіль точно таким, як на сервері.',+ 'This device, before signing in': 'Цей пристрій, до входу',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex 71825eaf0..b684c7db7 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -1922,4 +1922,9 @@ export default {'Options: copy, remove': '選項:複製、刪除','Another device synced while you were importing, so its changes were kept next to the backup.': '匯入時另一台裝置同步了,所以它的變更也和備份一起保留了。','Save as a backup file': '儲存為備份檔案',+ 'Add this device\'s plan to your profile?': '是否將此裝置上的計畫加入你的個人檔案?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '此裝置在未登入狀態下設定了計畫、備註或健身房卡。是否將其加入你的個人檔案,或是維持伺服器上的原本紀錄?',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '此裝置在未登入狀態下建立了 {0} 個訓練菜單。是否將其加入你的個人檔案,或是維持伺服器上的原本紀錄?',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '此裝置在未登入狀態下建立了 {0} 個訓練菜單。是否將其加入你的個人檔案,或是維持伺服器上的原本紀錄?',+ 'This device, before signing in': '此裝置(登入前)',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex a0d944b34..e4a563574 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1929,4 +1929,9 @@ export default {'Options: copy, remove': '选项:复制、删除','Another device synced while you were importing, so its changes were kept next to the backup.': '导入时另一台设备同步了,所以它的更改也和备份一起保留了。','Save as a backup file': '保存为备份文件',+ 'Add this device\'s plan to your profile?': '把此设备上的计划加入你的个人资料?',+ 'Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '此设备在未登录时设置了计划、备注或健身房卡。把它们加入你的个人资料,或保持个人资料与服务器上的完全一致。',+ '{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.': '此设备在未登录时创建了 {0} 个训练计划。把它加入你的个人资料,或保持个人资料与服务器上的完全一致。',+ '{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.': '此设备在未登录时创建了 {0} 个训练计划。把它们加入你的个人资料,或保持个人资料与服务器上的完全一致。',+ 'This device, before signing in': '此设备(登录前)',}diff --git a/frontend/src/sheets.add-device-data.test.jsx b/frontend/src/sheets.add-device-data.test.jsxindex 1185f0187..9e553c3fe 100644--- a/frontend/src/sheets.add-device-data.test.jsx+++ b/frontend/src/sheets.add-device-data.test.jsx@@ -3,7 +3,7 @@// singular ("1 workout and 1 weigh-in"), per noun, in English and in the packs.import { afterEach, describe, expect, it } from 'vitest'import { _setLangState } from './lib/i18n-core.js'-import { addDeviceDataMessage } from './sheets.jsx'+import { addDeviceDataMessage, addDeviceSetupMessage } from './sheets.jsx'import de from './locales/de.js'import ru from './locales/ru.js'@@ -27,4 +27,13 @@ describe('addDeviceDataMessage', () => {_setLangState('ru', ru, null, null)expect(addDeviceDataMessage(1, 1)).toMatch(/^1 тренировка и 1 взвешивание/)})++ it('a plan made while signed out has words of its own', () => {+ _setLangState('en', null, null, null)+ expect(addDeviceSetupMessage(1)).toMatch(/^1 routine was made on this device/)+ expect(addDeviceSetupMessage(3)).toMatch(/^3 routines were made on this device/)+ expect(addDeviceSetupMessage(0)).toMatch(/^Your plan, notes or gym cards/)+ _setLangState('de', de, null, null)+ expect(addDeviceSetupMessage(2)).toMatch(/^2 Routinen wurden/)+ })})diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 551d3726c..e5e4a6928 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -88,10 +88,21 @@ export function addDeviceDataMessage(workouts, weighIns) {// Sign-in found workouts on this device that the profile does not have (logged while signed// out). The profile is the truth — settings and plan come from the server either way — the// question is only whether these entries are added to it or dropped. Resolves true to add.+// Routines and the rest of a plan made here while signed out: asked about as well (they come along+// with "Add them"), in their own words when there is nothing else.+export function addDeviceSetupMessage(routines) {+ const n = Number(routines) || 0+ return n === 0+ ? t('Your plan, notes or gym cards on this device were set up while signed out. Add them to your profile, or keep the profile exactly as it is on the server.')+ : n === 1+ ? t('{0} routine was made on this device while signed out. Add it to your profile, or keep the profile exactly as it is on the server.', n)+ : t('{0} routines were made on this device while signed out. Add them to your profile, or keep the profile exactly as it is on the server.', n)+}export function askAddDeviceData(extras) {+ const logged = extras.workouts || extras.bodyweight || extras.customExreturn new Promise(resolve => confirmSheet({- title: t('Add this device\'s workouts to your profile?'),- message: addDeviceDataMessage(extras.workouts, extras.bodyweight),+ title: logged ? t('Add this device\'s workouts to your profile?') : t('Add this device\'s plan to your profile?'),+ message: logged ? addDeviceDataMessage(extras.workouts, extras.bodyweight) : addDeviceSetupMessage(extras.routines),confirmText: t('Add them'), cancelText: t('Keep profile as is'),onConfirm: () => resolve(true), onCancel: () => resolve(false), locked: true}))diff --git a/frontend/src/store/useStore.adopt.test.jsx b/frontend/src/store/useStore.adopt.test.jsxindex c84ce5955..9e8160582 100644--- a/frontend/src/store/useStore.adopt.test.jsx+++ b/frontend/src/store/useStore.adopt.test.jsx@@ -36,7 +36,7 @@ describe('adoptProfile — sign-in takes the server profile', () => {api.mockResolvedValueOnce({ state: clone(server), rev: 4 })const ask = vi.fn(async () => false)const r = await useStore.getState().adoptProfile(ask)- expect(ask).toHaveBeenCalledWith({ workouts: 1, bodyweight: 0, customEx: 0 })+ expect(ask).toHaveBeenCalledWith(expect.objectContaining({ workouts: 1, bodyweight: 0, customEx: 0 }))const S = useStore.getState().Sexpect(S.unit).toBe('lb'); expect(S.restSec).toBe(60)expect(S.workouts.map(w => w.id)).toEqual(['w1'])@@ -54,7 +54,8 @@ describe('adoptProfile — sign-in takes the server profile', () => {api.mockResolvedValueOnce({ ok: true, rev: 5 })await useStore.getState().adoptProfile(async () => true)const S = useStore.getState().S- expect(S.unit).toBe('lb'); expect(S.week).toEqual({ 1: ['r1'] })+ // the profile's plan, with the device's day added where the profile had nothing planned+ expect(S.unit).toBe('lb'); expect(S.week).toEqual({ 1: ['r1'], 2: ['rg'] })expect(S.workouts.map(w => w.id)).toEqual(['w1', 'w9'])expect(S.routines.map(x => x.id).sort()).toEqual(['r1', 'rg'])expect(puts()).toHaveLength(1)@@ -93,7 +94,7 @@ describe('adoptProfile — sign-in takes the server profile', () => {api.mockResolvedValueOnce({ state: null, rev: 0 })const ask = vi.fn(async () => false)const r = await useStore.getState().adoptProfile(ask, { alwaysAsk: true })- expect(ask).toHaveBeenCalledWith({ workouts: 1, bodyweight: 0, customEx: 0 })+ expect(ask).toHaveBeenCalledWith(expect.objectContaining({ workouts: 1, bodyweight: 0, customEx: 0 }))expect(puts()).toHaveLength(0)const S = useStore.getState().Sexpect(S.workouts).toEqual([])@@ -252,7 +253,7 @@ describe('web sign-in: nothing syncs while the question is open', () => {const ask = vi.fn(async () => false)api.mockResolvedValueOnce({ state: clone(server), rev: 4 })await useStore.getState().resumeAdoption(ask)- expect(ask).toHaveBeenCalledWith({ workouts: 1, bodyweight: 0, customEx: 0 })+ expect(ask).toHaveBeenCalledWith(expect.objectContaining({ workouts: 1, bodyweight: 0, customEx: 0 }))expect(puts()).toHaveLength(0)expect(useStore.getState().S.workouts.map(w => w.id)).toEqual(['w1'])expect(localStorage.getItem('gym_adopt')).toBeNull()@@ -273,7 +274,7 @@ describe('the sign-in hold: never stuck, and only about what the device had', ()window.dispatchEvent(new Event('online'))await vi.waitFor(() => expect(localStorage.getItem('gym_adopt')).toBeNull())await settle()- expect(sheetAsk).toHaveBeenCalledWith({ workouts: 1, bodyweight: 0, customEx: 0 })+ expect(sheetAsk).toHaveBeenCalledWith(expect.objectContaining({ workouts: 1, bodyweight: 0, customEx: 0 }))expect(useStore.getState().S.workouts.map(w => w.id)).toEqual(['w1'])expect(useStore.getState().sync.status).not.toBe('held')})@@ -302,7 +303,7 @@ describe('the sign-in hold: never stuck, and only about what the device had', ()api.mockResolvedValueOnce({ state: clone(server), rev: 4 })api.mockResolvedValueOnce({ ok: true, rev: 5 })await useStore.getState().syncNow()- expect(sheetAsk).toHaveBeenCalledWith({ workouts: 1, bodyweight: 0, customEx: 0 }) // w9 only+ expect(sheetAsk).toHaveBeenCalledWith(expect.objectContaining({ workouts: 1, bodyweight: 0, customEx: 0 })) // w9 onlyexpect(useStore.getState().S.workouts.map(w => w.id)).toEqual(['w1', 'w-later'])const put = puts().at(-1)expect(put.baseRev).toBe(4)diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex a04ede409..e7e84cd8b 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -941,6 +941,18 @@ export const useStore = create((set, get) => {await writeStashes(all)}+ // "Keep profile as is": what this device held before the sign-in leaves the screen, but not the+ // device. It is kept aside like a kept change (its own key, never added back on its own) and can+ // be saved as a backup file from Settings, in case the answer was the wrong one.+ const keepDeviceCopy = async () => {+ const S = get().S+ if (!hasData(S)) return+ const all = await readStashes()+ const uid = 'device-' + Date.now().toString(36)+ all[stashKey(serverBase(), uid)] = { server: serverBase() || null, uid, name: t('This device, before signing in'), at: Date.now(), state: clone(S) }+ await writeStashes(all)+ }+// adoptProfile's work (see there). Every way out answers the question — releaseAdopt — before// the decision is written and pushed; only a server that could not be reached leaves it owed.const runAdopt = async (ask, { alwaysAsk = false } = {}) => {@@ -963,7 +975,7 @@ export const useStore = create((set, get) => {reached()let asked = falseconst askAbout = async extras => {- if (!(extras.workouts || extras.bodyweight || extras.customEx) || typeof ask !== 'function') return false+ if (!(extras.workouts || extras.bodyweight || extras.customEx || extras.routines || extras.setup) || typeof ask !== 'function') return falseasked = truereturn !!(await ask(extras))}@@ -986,6 +998,7 @@ export const useStore = create((set, get) => {const push = hasData(S0) && (!alwaysAsk || sameAccount || await askAbout(localExtras(S0, null)))releaseAdopt()if (hasData(get().S) && !push) {+ if (asked) await keepDeviceCopy()takeServer()await applyStash()return { adopted: true, added: false }@@ -1029,6 +1042,11 @@ export const useStore = create((set, get) => {const S = get().Sconst merged = Object.assign(clone(DEF), mergeStates(state, S, { prefer: 'a' }))merged.active = carryActive(S, merged)+ // The account's plan wins; a day it has nothing planned for takes the device's.+ for (const f of ['week', 'dayPlan']) {+ const mine = S[f] && typeof S[f] === 'object' ? S[f] : {}+ merged[f] = { ...mine, ...(merged[f] || {}) }+ }persist(merged, false)if (rev != null) writeSync(rev, 0, state?._wid)else dropSync()@@ -1037,6 +1055,7 @@ export const useStore = create((set, get) => {return { adopted: true, added: true }}const later = pre ? splitByPre(get().S, pre).later : null+ if (asked) await keepDeviceCopy()takeServer()if (later) {const S = get().Sdiff --git a/frontend/src/store/useStore.signin-safety.test.jsx b/frontend/src/store/useStore.signin-safety.test.jsxindex ea834bcea..20d0cb456 100644--- a/frontend/src/store/useStore.signin-safety.test.jsx+++ b/frontend/src/store/useStore.signin-safety.test.jsx@@ -68,3 +68,41 @@ describe('sign-in "Add them" keeps the account\'s own entries and history', () =expect(merged.favEx).toContain('0025')})})++describe('sign-in asks about a plan built while signed out, and keeps what it drops', () => {+ const server = () => ({ ...clone(DEF), _ts: Date.now() - 1e6, routines: [{ id: 'sr1', name: 'Push Day', ex: [] }], week: { 1: 'sr1' }, workouts: [{ id: 'sw1', d: '2026-09-01', start: 1, entries: [] }], _rev: 7 })+ const guestPlan = () => {+ up(s => {+ s.routines = [{ id: 'g1', name: 'LOCAL A', ex: [] }, { id: 'g2', name: 'LOCAL B', ex: [] }]+ s.week = { 1: 'g1', 4: 'g2' }+ s.exNotes = { '0025': 'elbows in' }+ s.gymCards = [{ id: 'card1', label: 'FitX', value: '123', fmt: 'qrcode' }]+ s.restSec = 75+ })+ }+ it('a guest with only a plan is asked; "Add them" keeps the routines, the free plan days, notes and cards', async () => {+ guestPlan()+ api.mockImplementation(async (p, o) => (o?.method === 'PUT' ? { ok: true, rev: 8 } : { state: server(), rev: 7 }))+ useStore.getState().setUser({ id: 'u1', name: 'x' }, { adopt: true })+ const ask = vi.fn(async () => true)+ await useStore.getState().adoptProfile(ask)+ expect(ask).toHaveBeenCalledWith(expect.objectContaining({ routines: 2, setup: 3 }))+ const S = useStore.getState().S+ expect(S.routines.map(r => r.id).sort()).toEqual(['g1', 'g2', 'sr1'])+ expect(S.week).toEqual({ 1: 'sr1', 4: 'g2' }) // the account's Monday, the device's Thursday+ expect(S.exNotes['0025']).toBe('elbows in')+ expect(S.gymCards.map(c => c.id)).toEqual(['card1'])+ })+ it('"Keep profile as is" keeps the device\'s copy aside, to save as a backup file', async () => {+ guestPlan()+ api.mockImplementation(async (p, o) => (o?.method === 'PUT' ? { ok: true, rev: 8 } : { state: server(), rev: 7 }))+ useStore.getState().setUser({ id: 'u1', name: 'x' }, { adopt: true })+ await useStore.getState().adoptProfile(async () => false)+ expect(useStore.getState().S.routines.map(r => r.id)).toEqual(['sr1'])+ const kept = await useStore.getState().keptChanges()+ expect(kept).toHaveLength(1)+ const state = await useStore.getState().keptState(kept[0].server, kept[0].uid)+ expect(state.routines.map(r => r.id)).toEqual(['g1', 'g2'])+ expect(state.restSec).toBe(75)+ })+})