fuzzyworld

north-star / commit

added features list to readme and added stay-awake logic to the page

0a0cb749fe5d36e4a59c927e34ffd91cd8901483 · Pavel Safronov · 2026-03-15 10:24:36 -0700 · parents 6cb482fe1d89

added features list to readme and added stay-awake logic to the page
 readme.md  | 10 ++++++++++
 src/app.js | 25 +++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/readme.md b/readme.md
index d935eba..fd16b58 100644
--- a/readme.md
+++ b/readme.md
@@ -37,6 +37,16 @@ App: [https://pavelsafronov.gitlab.io/north-star/](https://pavelsafronov.gitlab.
 
 ## Dev stuff
 
+## New Features
+
+Ideas worth tracking (not implemented yet):
+
+- Optional user-facing low-power tracking mode toggle (battery saver style control).
+- Participant stale-state UX polish (for example: clearer badges, subtle icons, better wording).
+- Optional wake-lock mode for situations where people want to keep the app active longer.
+- Optional native-wrapper path (Capacitor/PWA strategy) for more reliable background location updates.
+- Export/share diagnostics mode for easier field testing (sensor availability, last sync times, etc.).
+
 ### Firebase database rules
 
 This repo includes Realtime Database security rules in [database.rules.json](database.rules.json).
diff --git a/src/app.js b/src/app.js
index ae679f0..790356f 100644
--- a/src/app.js
+++ b/src/app.js
@@ -40,6 +40,28 @@ let headingCorrectionDeg = (() => {
 })();
 let isLocalCommit = true;
 let GIT_COMMIT = 'local-dev';
+let wakeLockSentinel = null;
+const hasWakeLockSupport = typeof navigator !== 'undefined' && 'wakeLock' in navigator;
+
+const requestWakeLock = async () => {
+    if (!hasWakeLockSupport) return;
+    if (document.visibilityState !== 'visible') return;
+    if (wakeLockSentinel) return;
+
+    try {
+        wakeLockSentinel = await navigator.wakeLock.request('screen');
+        wakeLockSentinel.addEventListener('release', () => {
+            wakeLockSentinel = null;
+            if (document.visibilityState === 'visible') {
+                void requestWakeLock();
+            }
+        });
+    } catch (err) {
+        // Wake lock can fail on unsupported browsers or restricted contexts.
+        console.debug('Wake lock request failed', err);
+    }
+};
+
 try {
     const commitModule = await import('./commit.js');
     if (typeof commitModule.GIT_COMMIT === 'string') {
@@ -954,8 +976,11 @@ window.addEventListener('deviceorientation', (event) => {
 document.addEventListener('visibilitychange', () => {
     if (document.visibilityState !== 'visible') return;
     scheduleCompassProbe();
+    void requestWakeLock();
 });
 
+void requestWakeLock();
+
 const participantsRef = ref(db, `rooms/${roomId}/participants`);
 // onValue(participantsRef, (snapshot) => {
 //     const participants = snapshot.val(); // object of uid → participant