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.

Connection bar: a phone kept local no longer shows 'not connected to a server' (#454)

Duarte Santos9d461c3c12ce
diff --git a/frontend/src/components/ServerSync.jsx b/frontend/src/components/ServerSync.jsx
index 4e3fa09a7..b49aa862e 100644
--- a/frontend/src/components/ServerSync.jsx
+++ b/frontend/src/components/ServerSync.jsx
@@ -92,9 +92,12 @@ export function connectionView(sync, { mobile = MOBILE, online = isOnline() } =
return err.code === 'not-paired'
? { tone: 'bad', icon: 'lock', action: 'pair', line: t('This phone is not connected to a server.'), banner: t('This phone is no longer paired with your server. Your changes are kept here.') }
: { tone: 'bad', icon: 'lock', action: 'pair', line: t('The server refuses this phone'), banner: t('Your server no longer accepts this phone. Your changes are kept here.') }
- default: // 'local': no server at all — chosen, so it is said quietly, but it is said
+ // 'local': no server at all. On a phone that is a choice that needs no reminder (#454, #369):
+ // Settings still says it and offers Connect, the bar stays away. A guest in a browser is on a
+ // server it could sign in to, so it still hears that its data stays in this browser.
+ default:
return mobile
- ? { tone: 'quiet', icon: 'lock', action: 'connect', line: t('On this phone only, not connected to a server'), banner: t('On this phone only, not connected to a server') }
+ ? { tone: 'quiet', icon: 'lock', action: 'connect', line: t('On this phone only, not connected to a server'), banner: null }
: { tone: 'quiet', icon: 'lock', action: canSignIn() ? 'signin' : null, line: t('Guest mode: your data lives only in this browser.'), banner: t('Guest mode: your data lives only in this browser.') }
}
}
diff --git a/frontend/src/components/SyncBanner.jsx b/frontend/src/components/SyncBanner.jsx
index 82cf00b1f..73046dc2e 100644
--- a/frontend/src/components/SyncBanner.jsx
+++ b/frontend/src/components/SyncBanner.jsx
@@ -12,11 +12,11 @@ export const PENDING_GRACE_MS = 5000
/* The connection, always in view while the app is not connected to a server: offline, the server
unreachable or answering with an error (its HTTP code, for whoever runs it), a server that no
- longer accepts this device, an answer that is not openGym's, and no server at all — a phone
- kept local, a guest in a browser. It cannot be dismissed; it goes when the condition does — or
- when Settings → "Show connection status" is off, and then a dot on Home says a problem is there.
- The first ones say what is wrong and that the changes are kept here, with the one thing to do
- about it (retry, pair again, sign in); the deliberate local setup only says so, quietly.
+ longer accepts this device, an answer that is not openGym's, and a guest in a browser. It
+ cannot be dismissed; it goes when the condition does — or when Settings → "Show connection
+ status" is off, and then a dot on Home says a problem is there. Each says what is wrong and
+ that the changes are kept here, with the one thing to do about it (retry, pair again, sign in).
+ A phone kept local never sees it (#454): no server is a choice there, not a problem.
Pinned under the status bar, above the page and the pinned workout and chat headers, below the
tab bar, the timer and every sheet. Its height goes into --conn on the root, which the page's
diff --git a/frontend/src/components/SyncBanner.test.jsx b/frontend/src/components/SyncBanner.test.jsx
index 0ed7d8265..ba5d9e0b3 100644
--- a/frontend/src/components/SyncBanner.test.jsx
+++ b/frontend/src/components/SyncBanner.test.jsx
@@ -9,7 +9,8 @@ globalThis.IS_REACT_ACT_ENVIRONMENT = true
/* The connection indicator: every way the app can be without its server gets a line that stays
while the condition lasts — offline, an error with its HTTP code, a server that refuses this
- device, an answer that is not openGym's, no server at all — and says what to do about it.
+ device, an answer that is not openGym's, a guest in a browser — and says what to do about it.
+ A phone kept local on purpose gets no line at all (#454).
Never in the public demo, never during the phone's first-launch choice, and a change merely
waiting for its push does not flash it. The store is a stand-in: its `sync` is what each test
sets; ServerSync.jsx (the words and the actions) is the real one. */
@@ -206,17 +207,27 @@ describe('not connected — it says so, and what to do', () => {
})
describe('no server at all', () => {
- it('a phone kept local says so quietly, with a way to connect', () => {
+ // #454, #369: local use on a phone is a choice, so no bar for it. Settings still names it and
+ // offers Connect (the line); only a server the phone was paired with can be missing.
+ it('a phone kept local shows no bar at all, only the Settings line says it', () => {
mocks.MOBILE = true
mocks.user = null
mocks.guest = true
mocks.sync = sync('local', { server: null })
render()
- expect(bar().className).toContain('quiet')
- expect(text()).toBe('On this phone only, not connected to a server')
- expect(label()).toBe('Connect')
- act(() => button().click())
- expect(openedConnect().dataset.again).toBe('false')
+ expect(bar()).toBeNull()
+ expect(conn()).toBe('')
+ const view = connectionView(sync('local', { server: null }), { mobile: true })
+ expect(view.banner).toBeNull()
+ expect(view.line).toBe('On this phone only, not connected to a server')
+ expect(view.action).toBe('connect')
+ })
+
+ it('a paired phone whose server cannot be reached still hears it', () => {
+ mocks.MOBILE = true
+ mocks.sync = sync('offline', { pending: true })
+ render()
+ expect(text()).toBe('Your server can’t be reached. Your changes are saved on this device and sync once it answers again.')
})
it('a guest in a browser: "Sign in" leads to Settings, where signing in and creating a profile are', () => {
@@ -316,7 +327,7 @@ describe('with the connection status switched off', () => {
it('hides the bar whatever it would say, and gives the page its height back', () => {
for (const [st, extra, who] of [
['offline', { pending: true }, {}], ['error', { lastError: { status: 502 } }, {}], ['auth', {}, {}], ['held', {}, {}],
- ['local', { server: null }, { MOBILE: true, user: null, guest: true }], ['local', {}, { user: null, guest: true }],
+ ['local', {}, { user: null, guest: true }],
]) {
Object.assign(mocks, { MOBILE: false, user: { id: 'u1', name: 'andi' }, guest: false }, who, { sync: sync(st, extra), S: { connStatus: true } })
both()
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index fd5770fce..9fb822fdf 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -726,7 +726,7 @@ export default function Settings({ page = null, find = null, via = null }) {
subtitle={t('Show the body weight card on Home.')}>
<Switch checked={S.showWeightCard !== false} onChange={v => update(s => { s.showWeightCard = v })} />
</Row>
- {/* The bar at the top that says the app is offline, kept local, or not synced (#369, #330).
+ {/* The bar at the top that says the app is offline, refused or not synced (#369, #330, #454).
Here and not under Server & sync, which a phone kept local never shows. */}
{!DEMO && <Row icon="cloud" iconTint="var(--blue)" title={t('Show connection status')}
subtitle={t('Off: the bar at the top is hidden. A dot on Home still warns when syncing is stuck.')}>