mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 21:02:28 +00:00
Update share menu auth handling
This commit is contained in:
1 parent
4c55e56955
commit
b70d263eff
3 files changed
+61
-6
No files matched your search
@@ -244,6 +244,10 @@ export class VideoModal {
|
||||
reason: "",
|
||||
parentCommentId: null,
|
||||
};
|
||||
this.shareNostrAuthState = {
|
||||
isLoggedIn: false,
|
||||
hasSigner: false,
|
||||
};
|
||||
this.commentThreadContext = {
|
||||
videoEventId: "",
|
||||
parentCommentId: null,
|
||||
@@ -2578,9 +2582,8 @@ export class VideoModal {
|
||||
}
|
||||
|
||||
buildModalShareMenuPanel({ document: doc, close }) {
|
||||
const isLoggedIn =
|
||||
this.commentComposerState.reason !== "login-required" &&
|
||||
!this.commentComposerState.disabled;
|
||||
const isLoggedIn = this.shareNostrAuthState.isLoggedIn;
|
||||
const hasSigner = this.shareNostrAuthState.hasSigner;
|
||||
|
||||
const hasMagnet = Boolean(
|
||||
(typeof this.activeVideo?.magnet === "string" &&
|
||||
@@ -2596,6 +2599,7 @@ export class VideoModal {
|
||||
document: doc,
|
||||
video: this.activeVideo,
|
||||
isLoggedIn,
|
||||
hasSigner,
|
||||
hasMagnet,
|
||||
hasCdn,
|
||||
context: "modal",
|
||||
@@ -2671,6 +2675,27 @@ export class VideoModal {
|
||||
}
|
||||
}
|
||||
|
||||
setShareNostrAuthState({ isLoggedIn, hasSigner } = {}) {
|
||||
const nextIsLoggedIn = Boolean(isLoggedIn);
|
||||
const nextHasSigner = Boolean(hasSigner);
|
||||
const previous = this.shareNostrAuthState;
|
||||
|
||||
if (
|
||||
previous &&
|
||||
previous.isLoggedIn === nextIsLoggedIn &&
|
||||
previous.hasSigner === nextHasSigner
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.shareNostrAuthState = {
|
||||
isLoggedIn: nextIsLoggedIn,
|
||||
hasSigner: nextHasSigner,
|
||||
};
|
||||
|
||||
this.refreshModalShareMenuPanel();
|
||||
}
|
||||
|
||||
buildModalMoreMenuPanel({ document: doc, close }) {
|
||||
const panel = createVideoMoreMenuPanel({
|
||||
document: doc,
|
||||
|
||||
@@ -313,6 +313,7 @@ export function createVideoShareMenuPanel({
|
||||
document: documentRef = null,
|
||||
video = null,
|
||||
isLoggedIn = false,
|
||||
hasSigner = false,
|
||||
hasMagnet = false,
|
||||
hasCdn = false,
|
||||
designSystem = null,
|
||||
@@ -338,10 +339,13 @@ export function createVideoShareMenuPanel({
|
||||
action: "share-nostr",
|
||||
dataset: { eventId: metadata.id },
|
||||
});
|
||||
if (!isLoggedIn) {
|
||||
const canShareOnNostr = Boolean(isLoggedIn) && Boolean(hasSigner);
|
||||
if (!canShareOnNostr) {
|
||||
nostrBtn.disabled = true;
|
||||
nostrBtn.classList.add("opacity-50", "cursor-not-allowed");
|
||||
nostrBtn.title = "Log in to share on Nostr";
|
||||
nostrBtn.title = isLoggedIn
|
||||
? "Connect a Nostr signer to share"
|
||||
: "Log in to share on Nostr";
|
||||
}
|
||||
|
||||
const magnetBtn = appendMenuAction(doc, list, {
|
||||
@@ -488,4 +492,3 @@ export function createVideoSettingsMenuPanel({
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user