setSnoozedUntil(Date.now() + SNOOZE_MS)}
+ title={t('keepAlive.title')}
+ >
+
+ {t('keepAlive.body', { gym: presence.gymName, from: fmtTime(presence.checkedInAt) })}
+
+
+
+
+
+
+ );
+}
diff --git a/app/src/i18n/locales/en/presence.json b/app/src/i18n/locales/en/presence.json
index 5825702..16838e9 100644
--- a/app/src/i18n/locales/en/presence.json
+++ b/app/src/i18n/locales/en/presence.json
@@ -5,8 +5,12 @@
"checkingIn": "Checking in…",
"checkedInHere": "You're in since {{time}}",
"checkOut": "Check out",
- "stillHere": "I'm still here",
- "stillHereDone": "Slot refreshed",
+ "keepAlive": {
+ "title": "Still at the gym?",
+ "body": "Your check-in at \"{{gym}}\" (since {{from}}) has had no activity for a while. Confirm you're still working out, or check out.",
+ "stay": "I'm still here",
+ "leave": "I'm leaving"
+ },
"activeElsewhere": "You are checked in at {{gym}}.",
"switchHere": "Switch to this gym",
"virtualNotice": "This is a virtual gym — check-in only works for real gyms.",
diff --git a/app/src/i18n/locales/pl/presence.json b/app/src/i18n/locales/pl/presence.json
index 6a37e95..f76e42c 100644
--- a/app/src/i18n/locales/pl/presence.json
+++ b/app/src/i18n/locales/pl/presence.json
@@ -5,8 +5,12 @@
"checkingIn": "Melduję…",
"checkedInHere": "Jesteś od {{time}}",
"checkOut": "Wychodzę",
- "stillHere": "Wciąż tu jestem",
- "stillHereDone": "Slot odświeżony",
+ "keepAlive": {
+ "title": "Nadal jesteś na siłowni?",
+ "body": "Meldunek w „{{gym}}” (od {{from}}) nie ma już dawno żadnej aktywności. Potwierdź, że wciąż ćwiczysz, albo się wymelduj.",
+ "stay": "Wciąż tu jestem",
+ "leave": "Wychodzę"
+ },
"activeElsewhere": "Jesteś zameldowany w siłowni {{gym}}.",
"switchHere": "Przepnij na tę siłownię",
"virtualNotice": "To wirtualna siłownia — meldunek działa tylko na realnych siłowniach.",
diff --git a/app/src/pages/gyms/GymDetail.tsx b/app/src/pages/gyms/GymDetail.tsx
index 197883e..b6069a0 100644
--- a/app/src/pages/gyms/GymDetail.tsx
+++ b/app/src/pages/gyms/GymDetail.tsx
@@ -22,7 +22,6 @@ import {
deleteGym,
deleteGymAnnouncement,
deleteGymException,
- presenceHeartbeat,
useActivePresence,
useGymAnnouncements,
useGymDetail,
@@ -445,18 +444,6 @@ export default function GymDetail() {
}
};
- const doStillHere = async () => {
- setPresenceBusy(true);
- try {
- await presenceHeartbeat();
- push(tp('stillHereDone'), 'info');
- } catch (e) {
- push((e as Error).message, 'error');
- } finally {
- setPresenceBusy(false);
- }
- };
-
const remove = async () => {
if (!gym) return;
setBusy(true);
@@ -580,16 +567,12 @@ export default function GymDetail() {
: undefined;
// Meldunek bytności (REAL) — akcje dla każdego użytkownika siłowni.
+ // „Wciąż tu jestem” celowo NIE ma tu przycisku: odświeżanie slotu obsługuje
+ // globalny PresenceKeepAliveModal (1 kontrolka = 1 miejsce).
const presenceActions: TopbarAction[] | undefined =
gym && gym.kind === 'REAL'
? presence && presence.gymId === gym.id
? [
- {
- label: tp('stillHere'),
- variant: 'secondary',
- disabled: presenceBusy,
- onClick: () => void doStillHere(),
- },
{
label: tp('checkOut'),
variant: 'secondary',
diff --git a/app/test/e2e/mock-api.ts b/app/test/e2e/mock-api.ts
index dcb903f..6f4c33a 100644
--- a/app/test/e2e/mock-api.ts
+++ b/app/test/e2e/mock-api.ts
@@ -1812,9 +1812,11 @@ export function mockApi(page: Page, opts: MockApiOptions = {}) {
return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ checkedOut: true }) });
});
- page.route('**/api/v1/me/presence/heartbeat', (route) =>
- route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ touched: activePresence != null }) }),
- );
+ page.route('**/api/v1/me/presence/heartbeat', (route) => {
+ // heartbeat odświeża slot — globalny modal keep-alive zamyka się po potwierdzeniu
+ if (activePresence) activePresence.lastActivityAt = new Date().toISOString();
+ return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ touched: activePresence != null }) });
+ });
page.route('**/api/v1/me/presence/history*', (route) =>
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ visits: presenceVisits }) }),
diff --git a/app/test/e2e/presence.spec.ts b/app/test/e2e/presence.spec.ts
index 5b2f970..f47fda3 100644
--- a/app/test/e2e/presence.spec.ts
+++ b/app/test/e2e/presence.spec.ts
@@ -82,9 +82,10 @@ test('meldunek i wymeldowanie z menu kontekstowego siłowni + licznik „teraz
await page.getByRole('button', { name: 'Idę ćwiczyć' }).click();
await expect(page.getByText('Zameldowany — udanego treningu')).toBeVisible();
- // po meldunku: akcje „Wciąż tu jestem” + „Wychodzę”, licznik rośnie
+ // po meldunku: akcja „Wychodzę”, licznik rośnie (brak przycisku „Wciąż tu jestem” —
+ // odświeżanie slotu to globalny modal keep-alive, nie kontrolka w topbarze)
await expect(page.getByRole('button', { name: 'Wychodzę' })).toBeVisible();
- await expect(page.getByRole('button', { name: 'Wciąż tu jestem' })).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Wciąż tu jestem' })).not.toBeVisible();
await expect(page.getByText('teraz: 1 osoba')).toBeVisible();
await page.getByRole('button', { name: 'Wychodzę' }).click();
@@ -248,3 +249,38 @@ test('profil → historia treningów: sekcja „Moje wizyty” z listą wizyt',
await expect(page.getByText('75 min', { exact: true })).toBeVisible();
await expect(page.getByText('QR', { exact: true })).toBeVisible();
});
+
+function stalePresence(): Record