From a2f7a7fcebd9ca6f73191044a18963e1d2ef739d Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Sun, 19 Apr 2026 13:43:13 -0400 Subject: [PATCH] Fix music optional auth to detect existing logged-in session on page load --- www/js/version.json | 6 +++--- www/music.html | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/www/js/version.json b/www/js/version.json index 5ea5545..42ae73f 100644 --- a/www/js/version.json +++ b/www/js/version.json @@ -1,5 +1,5 @@ { - "VERSION": "v0.7.2", - "VERSION_NUMBER": "0.7.2", - "BUILD_DATE": "2026-04-19T17:37:32.473Z" + "VERSION": "v0.7.3", + "VERSION_NUMBER": "0.7.3", + "BUILD_DATE": "2026-04-19T17:43:13.562Z" } diff --git a/www/music.html b/www/music.html index a6bfd71..46cd46e 100644 --- a/www/music.html +++ b/www/music.html @@ -1617,6 +1617,21 @@ import { GreyscaleAPI } from './js/greyscale-api.mjs'; return message.includes('authentication required'); } + async function tryGetPubkeyWithoutPrompt({ attempts = 8, delayMs = 350 } = {}) { + for (let i = 0; i < attempts; i += 1) { + try { + const pubkey = await getPubkey(); + if (pubkey) return pubkey; + } catch { + // Signer can attach slightly after initial script execution. + } + if (i < attempts - 1) { + await new Promise((resolve) => setTimeout(resolve, delayMs)); + } + } + return ''; + } + function isReadOnlyTargetMode() { return Boolean(targetPubkey && (!currentPubkey || targetPubkey !== currentPubkey)); } @@ -1695,13 +1710,8 @@ import { GreyscaleAPI } from './js/greyscale-api.mjs'; throw error; } - try { - currentPubkey = await getPubkey(); - isAuthenticated = Boolean(currentPubkey); - } catch { - currentPubkey = null; - isAuthenticated = false; - } + currentPubkey = await tryGetPubkeyWithoutPrompt(); + isAuthenticated = Boolean(currentPubkey); } async function initializeAuthenticatedPageFeatures() {