From f4925a27264b16375b526b8cc351173e6b7c8f2c Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Mon, 6 Oct 2025 21:45:53 -0400 Subject: [PATCH] Fix channel video playback and stabilize edit gear menu --- js/channelProfile.js | 51 +++++++++++++++++++++++++++++++++++ js/ui/components/VideoCard.js | 1 + 2 files changed, 52 insertions(+) diff --git a/js/channelProfile.js b/js/channelProfile.js index 20cb7549..fa2a0d9a 100644 --- a/js/channelProfile.js +++ b/js/channelProfile.js @@ -1963,6 +1963,57 @@ async function loadUserVideos(pubkey) { app?.attachMoreMenuHandlers?.(container); + if (!container.dataset.playHandlerBound) { + container.addEventListener("click", (event) => { + if (!event || !(event.target instanceof HTMLElement)) { + return; + } + + const trigger = event.target.closest("[data-play-url],[data-play-magnet]"); + if (!trigger || !(trigger instanceof HTMLElement)) { + return; + } + + const isPrimaryClick = + typeof event.button !== "number" || event.button === 0; + if (!isPrimaryClick || event.ctrlKey || event.metaKey) { + return; + } + + if (!container.contains(trigger)) { + return; + } + + event.preventDefault(); + + const dataset = trigger.dataset || {}; + const videoId = dataset.videoId || trigger.getAttribute("data-video-id") || ""; + if (videoId && typeof app?.playVideoByEventId === "function") { + app.playVideoByEventId(videoId); + return; + } + + const rawUrl = dataset.playUrl || trigger.getAttribute("data-play-url") || ""; + let url = ""; + if (typeof rawUrl === "string" && rawUrl) { + try { + url = decodeURIComponent(rawUrl); + } catch (error) { + url = rawUrl; + } + } + + const magnetValue = + dataset.playMagnet || trigger.getAttribute("data-play-magnet") || ""; + const magnet = typeof magnetValue === "string" ? magnetValue : ""; + + if (typeof app?.playVideoWithFallback === "function") { + app.playVideoWithFallback({ url, magnet }); + } + }); + container.dataset.playHandlerBound = "true"; + } + // Gear menu toggles const gearButtons = container.querySelectorAll("[data-settings-dropdown]"); gearButtons.forEach((btn) => { diff --git a/js/ui/components/VideoCard.js b/js/ui/components/VideoCard.js index be262245..b0e9f26d 100644 --- a/js/ui/components/VideoCard.js +++ b/js/ui/components/VideoCard.js @@ -995,6 +995,7 @@ export class VideoCard { if (this.settingsButton && this.settingsDropdown) { this.settingsButton.addEventListener("click", (event) => { event.preventDefault(); + event.stopPropagation(); const willOpen = this.settingsDropdown.classList.contains("hidden"); if (this.onRequestCloseAllMenus) { this.onRequestCloseAllMenus(this);