From c5ddb82cbacc912a97fd13058c4fde14df2780ab Mon Sep 17 00:00:00 2001 From: ScreenTinker Date: Wed, 8 Jul 2026 12:56:39 -0500 Subject: [PATCH] fix(dashboard): device-detail.js parse + runtime errors that killed the whole view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #150 re-adopt commit (74e7062) left device-detail.js unparseable and, once parsed, unexecutable — so the entire device-detail view's JS was dead (settings, #150 re-adopt UI, delete): - SyntaxError at 768: `await api.getContent()` at the top level of the non-async setupActions() ("Unexpected reserved word") -> the whole module fails to parse. Fixed with the .then() pattern already used by the sibling playlist picker, keeping setupActions synchronous so every listener below it (save, #150 re-adopt, delete) still registers immediately (making it async would defer them behind the fetch). - Stray `async` orphaned on its own line (was line 648) before showReAdoptModal's doc comment: parses, but executes as the bare identifier statement `async;` -> ReferenceError at module load, which would keep the view dead even after the parse fix. Removed it. Also add beside the apple- one (clears the deprecation warning). Full frontend ES-module parse-scan clean; both bugs were confined to this file. Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/index.html | 1 + frontend/js/views/device-detail.js | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 89c14f9..9a09957 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,6 +5,7 @@ + diff --git a/frontend/js/views/device-detail.js b/frontend/js/views/device-detail.js index 4e2088a..4d73522 100644 --- a/frontend/js/views/device-detail.js +++ b/frontend/js/views/device-detail.js @@ -645,7 +645,7 @@ function showDevicePreview(device) { }); } -async // #150 re-adopt fallback: browse the workspace's previously-removed device snapshots and +// #150 re-adopt fallback: browse the workspace's previously-removed device snapshots and // apply one onto THIS (usually blank, just-re-paired) device. Primary restore is the silent // fingerprint-match on re-pair; this is for factory-reset / new-hardware / changed-fingerprint. const ORIENT_LABELS = { @@ -763,9 +763,11 @@ function setupActions(device) { } }); - // Populate default content dropdown - try { - const content = await api.getContent(); + // Populate default content dropdown (async, non-blocking — same .then() pattern as the + // playlist picker below). setupActions is a SYNCHRONOUS function; awaiting here made the whole + // file fail to parse ("Unexpected reserved word") AND would have deferred every listener below + // (save, #150 re-adopt, delete) until this fetch resolved. .then() keeps them registering immediately. + api.getContent().then(content => { const defaultSelect = document.getElementById('deviceDefaultContent'); if (defaultSelect) { content.forEach(c => { @@ -775,7 +777,7 @@ function setupActions(device) { defaultSelect.appendChild(opt); }); } - } catch {} + }).catch(() => {}); // Save settings (notes + orientation + default content) // Debug logging toggle: sends a transient set_debug command to the device and