diff --git a/js/app.js b/js/app.js index 6f7d4826..882cf31f 100644 --- a/js/app.js +++ b/js/app.js @@ -7351,6 +7351,29 @@ class Application { return; } + const { autoHideMs, showSpinner } = + options && typeof options === "object" ? options : Object.create(null); + + const shouldShowSpinner = showSpinner !== false; + const existingSpinner = container.querySelector(".status-spinner"); + + if (shouldShowSpinner) { + if (!(existingSpinner instanceof HTMLElementCtor)) { + const spinner = ownerDocument?.createElement?.("span") || null; + if (spinner) { + spinner.className = "status-spinner"; + spinner.setAttribute("aria-hidden", "true"); + if (messageTarget && container.contains(messageTarget)) { + container.insertBefore(spinner, messageTarget); + } else { + container.insertBefore(spinner, container.firstChild); + } + } + } + } else if (existingSpinner instanceof HTMLElementCtor) { + existingSpinner.remove(); + } + if (!msg) { if (messageTarget && messageTarget instanceof HTMLElementCtor) { messageTarget.textContent = ""; @@ -7360,9 +7383,6 @@ class Application { return; } - const { autoHideMs } = - options && typeof options === "object" ? options : Object.create(null); - if (messageTarget && messageTarget instanceof HTMLElementCtor) { messageTarget.textContent = msg; } else { diff --git a/js/channelProfile.js b/js/channelProfile.js index 5f454cba..a1a10e9e 100644 --- a/js/channelProfile.js +++ b/js/channelProfile.js @@ -506,10 +506,7 @@ function setChannelZapVisibility(visible) { typeof app?.isUserLoggedIn === "function" ? app.isUserLoggedIn() : Boolean(app?.normalizeHexPubkey?.(app?.pubkey)); - const sessionActorPubkey = getSessionActorPubkey(); - const hasSessionActor = sessionActorPubkey.length > 0; - const sessionOnly = !isLoggedIn && hasSessionActor; - const shouldShow = !!visible && (isLoggedIn || sessionOnly); + const shouldShow = !!visible; const requiresLogin = shouldShow && !isLoggedIn; if ( diff --git a/js/payments/zapNotifications.js b/js/payments/zapNotifications.js index 0e10c3f8..36cd0848 100644 --- a/js/payments/zapNotifications.js +++ b/js/payments/zapNotifications.js @@ -3,7 +3,7 @@ import { getApplication } from "../applicationContext.js"; import { LOGIN_TO_ZAP_MESSAGE } from "./zapMessages.js"; -const LOGIN_NOTIFICATION_AUTO_HIDE_MS = 5000; +const LOGIN_NOTIFICATION_AUTO_HIDE_MS = 3000; function getOwnerDocument(node) { return node?.ownerDocument || null; @@ -38,12 +38,12 @@ function isNotificationBannerActive({ return text === expectedText; } -function attemptStatusBanner(app, { autoHideMs, expectedText }) { +function attemptStatusBanner(app, { autoHideMs, expectedText, showSpinner }) { if (!app || typeof app.showStatus !== "function") { return false; } - app.showStatus(expectedText, { autoHideMs }); + app.showStatus(expectedText, { autoHideMs, showSpinner }); return isNotificationBannerActive({ container: app.statusContainer, @@ -108,7 +108,12 @@ function ensureNotificationPortal({ doc, HTMLElementCtor }) { return portal instanceof HTMLElementCtor ? portal : null; } -function ensureStatusContainer({ doc, portal, HTMLElementCtor }) { +function ensureStatusContainer({ + doc, + portal, + HTMLElementCtor, + includeSpinner = true, +}) { if (!doc || !HTMLElementCtor) { return { container: null, messageTarget: null }; } @@ -123,10 +128,12 @@ function ensureStatusContainer({ doc, portal, HTMLElementCtor }) { statusContainer.setAttribute("role", "status"); statusContainer.setAttribute("aria-live", "polite"); - const spinner = doc.createElement("span"); - spinner.className = "status-spinner"; - spinner.setAttribute("aria-hidden", "true"); - statusContainer.appendChild(spinner); + if (includeSpinner) { + const spinner = doc.createElement("span"); + spinner.className = "status-spinner"; + spinner.setAttribute("aria-hidden", "true"); + statusContainer.appendChild(spinner); + } const message = doc.createElement("span"); message.className = "status-message"; @@ -134,11 +141,15 @@ function ensureStatusContainer({ doc, portal, HTMLElementCtor }) { statusContainer.appendChild(message); } else { const existingSpinner = statusContainer.querySelector(".status-spinner"); - if (!(existingSpinner instanceof HTMLElementCtor)) { - const spinner = doc.createElement("span"); - spinner.className = "status-spinner"; - spinner.setAttribute("aria-hidden", "true"); - statusContainer.insertBefore(spinner, statusContainer.firstChild); + if (includeSpinner) { + if (!(existingSpinner instanceof HTMLElementCtor)) { + const spinner = doc.createElement("span"); + spinner.className = "status-spinner"; + spinner.setAttribute("aria-hidden", "true"); + statusContainer.insertBefore(spinner, statusContainer.firstChild); + } + } else if (existingSpinner instanceof HTMLElementCtor) { + existingSpinner.remove(); } } @@ -275,7 +286,7 @@ export function showLoginRequiredToZapNotification({ getOwnerDocument(app?.statusContainer) || getOwnerDocument(app?.errorContainer); - if (attemptStatusBanner(app, { autoHideMs, expectedText })) { + if (attemptStatusBanner(app, { autoHideMs, expectedText, showSpinner: false })) { return true; } @@ -299,6 +310,7 @@ export function showLoginRequiredToZapNotification({ doc, portal, HTMLElementCtor, + includeSpinner: false, }); if (statusContainer instanceof HTMLElementCtor) { diff --git a/js/ui/zapController.js b/js/ui/zapController.js index 53c99cde..4587cf90 100644 --- a/js/ui/zapController.js +++ b/js/ui/zapController.js @@ -97,9 +97,7 @@ export default class ZapController { setVisibility(visible) { const lightningVisible = !!visible; const loggedIn = this.isUserLoggedIn(); - const sessionActorAvailable = this.hasSessionActor(); - const shouldShow = - lightningVisible && (loggedIn || sessionActorAvailable); + const shouldShow = lightningVisible; const requiresLogin = shouldShow && !loggedIn; const hasWallet = this.hasActiveWalletConnection(); if (this.videoModal) {