mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 16:02:26 +00:00
Refactor video modal sharing options into a unified Share menu
- Replaced the standalone "Copy Magnet" button and "Share" button with a new Share menu. - Implemented `createVideoShareMenuPanel` to render the new menu with "Copy URL", "Share on Nostr", "Copy Magnet", and "Copy CDN Link" options. - Updated `VideoModal.js` to manage the share menu state and handle actions. - Added `video:share-nostr` and `video:copy-cdn` event handlers in `app.js`. - Removed the `#copyMagnetBtn` element from `video-modal.html`. - Preserved existing functionality for "Copy URL" and "Copy Magnet". - "Share on Nostr" is currently a placeholder logging a message, disabled for logged-out users. - "Copy CDN Link" is disabled if no URL is available.
This commit is contained in:
1 parent
4c9ae3b882
commit
bd868fb7ea
8 files changed
+140
-24
No files matched your search
@@ -304,25 +304,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="video-modal__actions-group">
|
||||
<button
|
||||
id="copyMagnetBtn"
|
||||
type="button"
|
||||
class="video-modal__action-button focus-ring accent-action-button"
|
||||
aria-label="Copy magnet"
|
||||
>
|
||||
<svg
|
||||
class="video-modal__action-icon icon-image"
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M17.374 20.235c2.444-2.981 6.626-8.157 6.626-8.157l-3.846-3.092s-2.857 3.523-6.571 8.097c-4.312 5.312-11.881-2.41-6.671-6.671 4.561-3.729 8.097-6.57 8.097-6.57l-3.092-3.842s-5.173 4.181-8.157 6.621c-2.662 2.175-3.76 4.749-3.76 7.24 0 5.254 4.867 10.139 10.121 10.139 2.487 0 5.064-1.095 7.253-3.765zm4.724-7.953l-1.699 2.111-1.74-1.397 1.701-2.114 1.738 1.4zm-10.386-10.385l1.4 1.738-2.113 1.701-1.397-1.74 2.11-1.699z"
|
||||
/>
|
||||
</svg>
|
||||
<span class="video-modal__action-label">Copy magnet</span>
|
||||
</button>
|
||||
<div class="popover" data-modal-zap-wrapper>
|
||||
<button
|
||||
id="modalZapBtn"
|
||||
|
||||
@@ -8459,7 +8459,7 @@ class Application {
|
||||
this.currentVideo.torrentSupported = !!magnetForPlayback;
|
||||
}
|
||||
this.currentMagnetUri = magnetForPlayback || null;
|
||||
this.setCopyMagnetState(!!magnetForPlayback);
|
||||
// this.setCopyMagnetState(!!magnetForPlayback); // Removed
|
||||
|
||||
const unsubscribers = [];
|
||||
const subscribe = (eventName, handler) => {
|
||||
@@ -8757,8 +8757,8 @@ class Application {
|
||||
|
||||
this.currentMagnetUri = sanitizedMagnet || null;
|
||||
|
||||
this.setCopyMagnetState(!!sanitizedMagnet);
|
||||
this.setShareButtonState(true);
|
||||
// this.setCopyMagnetState(!!sanitizedMagnet); // Removed
|
||||
// this.setShareButtonState(true); // Moved to after showModalWithPoster
|
||||
|
||||
const nevent = window.NostrTools.nip19.neventEncode({ id: eventId });
|
||||
const pushUrl =
|
||||
@@ -8781,6 +8781,8 @@ class Application {
|
||||
|
||||
await this.showModalWithPoster(this.currentVideo);
|
||||
|
||||
this.setShareButtonState(true);
|
||||
|
||||
this.commentController?.load(this.currentVideo);
|
||||
|
||||
const playbackOptions = {
|
||||
@@ -9131,8 +9133,8 @@ class Application {
|
||||
|
||||
this.currentMagnetUri = sanitizedMagnet || null;
|
||||
|
||||
this.setCopyMagnetState(!!sanitizedMagnet);
|
||||
this.setShareButtonState(false);
|
||||
// this.setCopyMagnetState(!!sanitizedMagnet);
|
||||
// this.setShareButtonState(false);
|
||||
|
||||
if (this.videoModal) {
|
||||
this.videoModal.updateMetadata({
|
||||
@@ -9150,6 +9152,8 @@ class Application {
|
||||
|
||||
await this.showModalWithPoster(this.currentVideo, hasTrigger ? { trigger } : {});
|
||||
|
||||
this.setShareButtonState(false);
|
||||
|
||||
this.commentController?.load(null);
|
||||
|
||||
const shareUrl = this.buildShareUrlFromEventId(this.currentVideo.id);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 327 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 325 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 327 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 315 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 327 KiB |
@@ -0,0 +1,131 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
def verify_share_menu(page):
|
||||
print("Navigating to app...")
|
||||
page.goto("http://localhost:8000")
|
||||
|
||||
# Wait for app to load
|
||||
print("Waiting for app to load...")
|
||||
try:
|
||||
# Just wait for anything to indicate readiness, cards might be lazy loaded
|
||||
page.wait_for_load_state("networkidle", timeout=5000)
|
||||
# Check for card container
|
||||
page.wait_for_selector("#videoList", timeout=5000)
|
||||
except Exception as e:
|
||||
print(f"Initial load wait error (ignoring): {e}")
|
||||
|
||||
# Handle disclaimer if present
|
||||
try:
|
||||
print("Checking for disclaimer...")
|
||||
disclaimer = page.query_selector("#disclaimerAgreeBtn")
|
||||
if disclaimer and disclaimer.is_visible():
|
||||
print("Disclaimer found, clicking agree...")
|
||||
page.click("#disclaimerAgreeBtn")
|
||||
page.wait_for_selector("#disclaimerModal", state="hidden", timeout=3000)
|
||||
print("Disclaimer dismissed.")
|
||||
else:
|
||||
print("No visible disclaimer found.")
|
||||
except Exception as e:
|
||||
print(f"Disclaimer check exception: {e}")
|
||||
|
||||
# Force a refresh of the cards or wait explicitly
|
||||
print("Waiting for any card...")
|
||||
try:
|
||||
page.wait_for_selector(".card", timeout=15000)
|
||||
except Exception as e:
|
||||
print(f"Failed to find cards: {e}")
|
||||
page.screenshot(path="verification/debug_no_cards.png")
|
||||
sys.exit(1)
|
||||
|
||||
# Click the first video card to open the modal
|
||||
print("Opening video modal...")
|
||||
try:
|
||||
# Use JS click as it is most reliable against overlays/scrolling
|
||||
page.evaluate("() => { const card = document.querySelector(\".card\"); if(card) { card.scrollIntoView(); card.click(); } else { throw new Error(\"No card found\"); } }")
|
||||
except Exception as e:
|
||||
print(f"Click evaluation failed: {e}")
|
||||
page.screenshot(path="verification/debug_click_fail.png")
|
||||
sys.exit(1)
|
||||
|
||||
# Wait for modal to open
|
||||
print("Waiting for modal...")
|
||||
try:
|
||||
# Check if modal is visible - use a function that returns true immediately if visible
|
||||
# We loop here to be safe and debug
|
||||
for i in range(20):
|
||||
is_visible = page.evaluate("() => { const el = document.getElementById(playerModal); return el && !el.hasAttribute(hidden) && !el.classList.contains(hidden); }")
|
||||
if is_visible:
|
||||
print("Modal is confirmed visible via JS.")
|
||||
break
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
print("Modal did not become visible.")
|
||||
page.screenshot(path="verification/debug_modal_not_visible.png")
|
||||
# sys.exit(1) # Dont exit yet, check if its maybe just taking long or other issue
|
||||
|
||||
except Exception as e:
|
||||
print(f"Modal check failed: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
# Verify "Copy Magnet" button is NOT in the main actions group
|
||||
print("Verifying absence of Copy Magnet button in main UI...")
|
||||
magnet_btn = page.query_selector("#copyMagnetBtn")
|
||||
if magnet_btn and page.evaluate("el => !el.hasAttribute(\"hidden\") && !el.classList.contains(\"hidden\")", magnet_btn):
|
||||
print("ERROR: Copy Magnet button is still visible in the main UI!")
|
||||
sys.exit(1)
|
||||
|
||||
# Find and click the Share button
|
||||
print("Clicking Share button...")
|
||||
try:
|
||||
# Ensure share button is visible/clickable
|
||||
# If modal wasnt visible to playwright but IS visible to JS, we might need force=True
|
||||
page.click("#shareBtn", force=True)
|
||||
except Exception as e:
|
||||
print(f"Failed to click share button: {e}")
|
||||
page.screenshot(path="verification/debug_share_btn_fail.png")
|
||||
sys.exit(1)
|
||||
|
||||
# Wait for the popover menu to appear
|
||||
print("Waiting for Share menu...")
|
||||
try:
|
||||
page.wait_for_selector("[data-menu=\"video-share\"]", timeout=5000)
|
||||
except Exception as e:
|
||||
print(f"Share menu did not appear: {e}")
|
||||
page.screenshot(path="verification/debug_share_menu_fail.png")
|
||||
sys.exit(1)
|
||||
|
||||
# Take a screenshot of the open menu
|
||||
print("Taking screenshot...")
|
||||
page.screenshot(path="verification/share_menu_verification.png")
|
||||
|
||||
# Verify menu items
|
||||
print("Verifying menu items...")
|
||||
menu = page.locator("[data-menu=\"video-share\"]")
|
||||
text_content = menu.inner_text()
|
||||
print(f"Menu content: {text_content}")
|
||||
|
||||
if "Copy URL" not in text_content:
|
||||
print("ERROR: Copy URL item missing")
|
||||
if "Share on Nostr" not in text_content:
|
||||
print("ERROR: Share on Nostr item missing")
|
||||
if "Copy Magnet" not in text_content:
|
||||
print("ERROR: Copy Magnet item missing")
|
||||
if "Copy CDN Link" not in text_content:
|
||||
print("ERROR: Copy CDN Link item missing")
|
||||
|
||||
print("Verification complete!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
page = browser.new_page()
|
||||
try:
|
||||
verify_share_menu(page)
|
||||
except Exception as e:
|
||||
print(f"Verification failed: {e}")
|
||||
sys.exit(1)
|
||||
finally:
|
||||
browser.close()
|
||||
Reference in new issue
Block a user