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.

Boot screen without an inline script, so the web CSP needs no new hash

Duarte Santosd377fb3f7569
diff --git a/frontend/index.html b/frontend/index.html
index 688d0ec38..34d683eb2 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -31,8 +31,8 @@
<body>
<!-- The boot screen: painted with the HTML, before any script runs, so the gap between the
native splash and the first real screen is the logo loading its plates instead of a black
- page. Same dark and lime as the native splash. App.jsx takes it away (window.__hideBoot)
- the moment it can draw, so it never adds a wait. -->
+ page. Same dark and lime as the native splash. lib/boot.js takes it away the moment the
+ app can draw, so it never adds a wait. -->
<style>
#boot{position:fixed;inset:0;z-index:2147483000;display:grid;place-items:center;background:#0c0e12;transition:opacity .22s ease-out}
#boot.out{opacity:0;pointer-events:none}
@@ -68,16 +68,6 @@
</g>
</svg>
</div>
-<script>
- window.__hideBoot = function () {
- var b = document.getElementById('boot')
- if (!b || b.className) return
- b.className = 'out'
- setTimeout(function () { b.remove() }, 260)
- }
- // A script that dies before the app draws would otherwise leave the logo lifting forever.
- window.addEventListener('error', window.__hideBoot, { once: true })
-</script>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index c55368290..435d29d55 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -1,4 +1,5 @@
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+import { hideBoot } from './lib/boot.js'
import { HashRouter, Routes, Route, Navigate, useNavigate, useLocation, useNavigationType } from 'react-router-dom'
import { useStore } from './store/useStore.js'
import { useUI } from './store/useUI.js'
@@ -228,7 +229,7 @@ function Shell() {
const authed = user || isGuest
// The boot screen in index.html covers the start; it goes once there is something to show.
- useEffect(() => { if (ready || authed) window.__hideBoot?.() }, [ready, authed])
+ useEffect(() => { if (ready || authed) hideBoot() }, [ready, authed])
if (!ready && !authed) return (
<div id="app">
<div style={{ paddingTop: '44vh', display: 'flex', justifyContent: 'center', fontSize: 34, color: 'var(--label-3)' }}>
diff --git a/frontend/src/lib/boot.js b/frontend/src/lib/boot.js
new file mode 100644
index 000000000..bc89cd934
--- /dev/null
+++ b/frontend/src/lib/boot.js
@@ -0,0 +1,8 @@
+// The boot screen in index.html: markup and CSS only, so the web image's CSP needs no new hash.
+// It goes the moment the app can draw, or on a script error before that, so it never lifts forever.
+export function hideBoot() {
+ const b = document.getElementById('boot')
+ if (!b || b.className) return
+ b.className = 'out'
+ setTimeout(() => b.remove(), 260)
+}
diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx
index e08383fc4..ae12b0052 100644
--- a/frontend/src/main.jsx
+++ b/frontend/src/main.jsx
@@ -6,8 +6,12 @@ import { useStore } from './store/useStore.js'
import { startMediaSync } from './lib/media-sync.js'
import { startNativeKeyboard } from './lib/native-keyboard.js'
import './index.css'
+import { hideBoot } from './lib/boot.js'
// App.jsx restores per-route scroll itself; the browser's own attempt races it.
+// A script that dies before the app draws would otherwise leave the boot logo lifting forever.
+window.addEventListener('error', hideBoot, { once: true })
+
if ('scrollRestoration' in history) history.scrollRestoration = 'manual'
createRoot(document.getElementById('root')).render(