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.

Push reminders: render the routine's glyph as an emoji, not as its own name

mzspicolica03931ac2c2
diff --git a/api/push-messages.js b/api/push-messages.js
index 37861a0b4..1f50e96d5 100644
--- a/api/push-messages.js
+++ b/api/push-messages.js
@@ -22,6 +22,26 @@ const COPY = {
const copyFor = lang => COPY[lang] || COPY.en;
+// A routine's `emoji` field held a literal emoji until the glyph redesign; since then it holds
+// an icon key ('dumbbell', 'figureRun') that the app renders as an SVG. A push notification has
+// no SVG to render, so an unmapped key reaches the phone as its own name — "dumbbell Push
+// today". Keys are ASCII and emoji are not, so anything ASCII is looked up here (falling back
+// rather than printing a word), and anything else is already an emoji and passes through.
+// Mirrors frontend/src/lib/glyphs.js: GLYPHS is the full set the picker offers.
+const DEFAULT_EMOJI = '🏋️';
+const GLYPH_EMOJI = {
+ figureStrength: '🏋️', arm: '💪', abs: '💥', legs: '🦵', pullup: '🧗',
+ dumbbell: '🏋️', barbell: '🏋️', kettlebell: '🏋️', plate: '🏋️', machine: '🏋️',
+ figureRun: '🏃', bike: '🚴', swim: '🏊', boxing: '🥊', timer: '⏱️',
+ stretch: '🤸', moon: '🌙', heart: '❤️', flame: '🔥', bolt: '⚡',
+};
+
+export function routineEmoji(value) {
+ if (!value) return DEFAULT_EMOJI;
+ if (!/^[A-Za-z]+$/.test(value)) return value;
+ return GLYPH_EMOJI[value] || DEFAULT_EMOJI;
+}
+
export function restTimerPush(lang) {
const copy = copyFor(lang);
return { title: copy.restTitle, body: copy.restBody, tag: 'rest-timer' };
@@ -35,7 +55,7 @@ export function dayReminderPush(lang, routine) {
const copy = copyFor(lang);
return {
title: routine
- ? `${routine.emoji || '🏋️'} ${routine.name} ${copy.dayRoutineSuffix}`
+ ? `${routineEmoji(routine.emoji)} ${routine.name} ${copy.dayRoutineSuffix}`
: copy.dayFallbackTitle,
body: copy.dayBody,
tag: 'day-reminder',
diff --git a/api/test/push-messages.test.js b/api/test/push-messages.test.js
index b8034d5ab..5868631bd 100644
--- a/api/test/push-messages.test.js
+++ b/api/test/push-messages.test.js
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
-import { dayReminderPush, restTimerPush, testPush } from '../push-messages.js';
+import { dayReminderPush, restTimerPush, routineEmoji, testPush } from '../push-messages.js';
test('localizes every server-generated notification in pt-BR', () => {
assert.deepEqual(restTimerPush('pt-BR'), {
@@ -25,3 +25,26 @@ test('keeps the existing English copy as the fallback', () => {
assert.equal(dayReminderPush('unknown', null).title, 'Workout planned today');
assert.equal(testPush(undefined).body, 'Test notification ✅ This is what alerts look like.');
});
+
+// Routines stopped storing a literal emoji when the glyph picker landed: `emoji` now holds an
+// icon key the app renders as an SVG. A notification has no SVG, so before this the reminder
+// read "dumbbell Push today" — the key's own name, on the lock screen.
+test('renders a routine glyph key as an emoji, never as its name', () => {
+ assert.equal(routineEmoji('dumbbell'), '🏋️');
+ assert.equal(routineEmoji('figureRun'), '🏃');
+ assert.equal(routineEmoji('legs'), '🦵');
+ assert.equal(
+ dayReminderPush('pt-BR', { name: 'Costas e Bíceps', emoji: 'dumbbell' }).title,
+ '🏋️ Costas e Bíceps hoje',
+ );
+});
+
+test('leaves a literal emoji alone and falls back for anything else', () => {
+ assert.equal(routineEmoji('💪'), '💪');
+ assert.equal(routineEmoji('🏋️‍♀️'), '🏋️‍♀️');
+ // An icon key the picker no longer offers is still ASCII, so it falls back to the default
+ // rather than reaching the phone as a word.
+ assert.equal(routineEmoji('trophy'), '🏋️');
+ assert.equal(routineEmoji(''), '🏋️');
+ assert.equal(routineEmoji(undefined), '🏋️');
+});