mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 13:22:54 +00:00
[ui] Make "Share on Nostr" a working button
The share menu's "Share on Nostr" entry was never clickable, no matter who was
logged in -- it rendered as inert, dimmed text.
VideoModal initialized `shareNostrAuthState` to { isLoggedIn: false, hasSigner:
false } and nothing ever wrote to it. createVideoShareMenuPanel gates the item
on `isLoggedIn && hasSigner`, so it was always disabled, and the click
delegation in bindShareMenuActions() bails on `button.disabled` -- so the whole
share-to-Nostr flow behind it was unreachable.
The renderer and the publish path were both already correct; only the gate was
missing:
- VideoModal.setShareNostrAuthState() records the state and closes an already
open share menu when it changes, so a menu opened before login does not keep
showing the stale disabled item. It is a no-op when nothing changed, to avoid
slamming the menu shut on every sync.
- syncAuthUiState() computes the gate from isUserLoggedIn() plus a
signing-capable active signer, mirroring ShareNostrController.handleShare():
a signer without signEvent would only produce an error toast on click.
- syncAuthUiState() was only ever called at bootstrap, so logging in
mid-session left the gate closed. It now self-installs a bitvid:auth-changed
listener on first run (bound once, re-entrancy safe) rather than adding a
call site in js/app.js, which is at its file-size cap.
Verified in a browser that the rendered item is disabled when logged out or
signer-less and enabled + click-dispatching with both; the new tests fail 5/9
with the gate push removed.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
b84558e928
commit
d141c316a9
3 files changed
+242
-1
No files matched your search
@@ -3453,6 +3453,32 @@ export class VideoModal {
|
||||
// Delegated click handler for the share popover's menu-action buttons
|
||||
// (Copy URL / Copy Magnet / Copy CDN / Share on Nostr). The forced-source
|
||||
// test links self-wire their own copy, so they are skipped here.
|
||||
/**
|
||||
* Update the login/signer gate for the share menu's "Share on Nostr" item.
|
||||
*
|
||||
* This state was initialized to `false` and never written, so
|
||||
* `createVideoShareMenuPanel` always rendered the item disabled — the entry
|
||||
* looked like inert text no matter who was logged in, and the click
|
||||
* delegation in bindShareMenuActions() bails on `button.disabled`. The app
|
||||
* pushes real state here from syncAuthUiState().
|
||||
*/
|
||||
setShareNostrAuthState({ isLoggedIn = false, hasSigner = false } = {}) {
|
||||
const next = { isLoggedIn: !!isLoggedIn, hasSigner: !!hasSigner };
|
||||
const changed =
|
||||
next.isLoggedIn !== this.shareNostrAuthState.isLoggedIn ||
|
||||
next.hasSigner !== this.shareNostrAuthState.hasSigner;
|
||||
this.shareNostrAuthState = next;
|
||||
|
||||
// The popover renders its panel on open, so a menu that is already open
|
||||
// would keep showing the stale (disabled) item. Close it so the next open
|
||||
// renders against current state.
|
||||
if (changed) {
|
||||
this.modalSharePopover?.close?.();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
bindShareMenuActions(panel) {
|
||||
if (!panel || typeof panel.addEventListener !== "function") {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user