From 1e388757ff01d9f5be062ce2078b9401198e20ed Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 25 Sep 2025 19:21:18 -0400 Subject: [PATCH] Align WebTorrent indicators with CDN badges --- js/app.js | 97 +++++++++++++++++++++++++++++++++++--------- js/channelProfile.js | 19 +++++++-- js/subscriptions.js | 36 ++++++++-------- 3 files changed, 113 insertions(+), 39 deletions(-) diff --git a/js/app.js b/js/app.js index 2be08ceb..552b9c3b 100644 --- a/js/app.js +++ b/js/app.js @@ -2132,10 +2132,28 @@ class bitvidApp { * so they can re-use the exact same badge skeleton. Keeping the markup in * one place avoids subtle mismatches when we tweak copy or classes later. */ - getUrlHealthPlaceholderMarkup() { + getUrlHealthPlaceholderMarkup(options = {}) { + const includeMargin = options?.includeMargin !== false; + const classes = [ + "url-health-badge", + "text-xs", + "font-semibold", + "px-2", + "py-1", + "rounded", + "inline-flex", + "items-center", + "gap-1", + "bg-gray-800", + "text-gray-300", + ]; + if (includeMargin) { + classes.splice(1, 0, "mt-3"); + } + return `
+ + 🟦 + + + WebTorrent + +
+ `; + } + + isMagnetUriSupported(magnet) { + return isValidMagnetUri(magnet); + } + getCachedUrlHealth(eventId, url) { return readUrlHealthFromCache(eventId, url); } @@ -2480,7 +2538,7 @@ class bitvidApp { const playbackMagnet = magnetCandidate; const showUnsupportedTorrentBadge = !trimmedUrl && magnetProvided && !magnetSupported; - const torrentBadge = showUnsupportedTorrentBadge + const torrentWarningHtml = showUnsupportedTorrentBadge ? `

+ ${urlBadgeHtml}${torrentHealthBadgeHtml} + + ` + : ""; const rawThumbnail = typeof video.thumbnail === "string" ? video.thumbnail.trim() : ""; @@ -2546,19 +2616,6 @@ class bitvidApp {

-
- - Streamable? - - - 🟦 - -

${gearMenu}

- ${urlStatusHtml} - ${torrentBadge} + ${connectionBadgesHtml} + ${torrentWarningHtml} `; diff --git a/js/channelProfile.js b/js/channelProfile.js index 8922b649..0292ba96 100644 --- a/js/channelProfile.js +++ b/js/channelProfile.js @@ -367,9 +367,22 @@ async function loadUserVideos(pubkey) { typeof video.url === "string" ? video.url : ""; const trimmedUrl = playbackUrl ? playbackUrl.trim() : ""; const playbackMagnet = rawMagnet || legacyInfoHash || ""; - const urlStatusHtml = trimmedUrl - ? app.getUrlHealthPlaceholderMarkup() + const magnetSupported = app.isMagnetUriSupported(playbackMagnet); + const urlBadgeHtml = trimmedUrl + ? app.getUrlHealthPlaceholderMarkup({ includeMargin: false }) : ""; + const torrentHealthBadgeHtml = + magnetSupported && playbackMagnet + ? app.getTorrentHealthBadgeMarkup({ includeMargin: false }) + : ""; + const connectionBadgesHtml = + urlBadgeHtml || torrentHealthBadgeHtml + ? ` +
+ ${urlBadgeHtml}${torrentHealthBadgeHtml} +
+ ` + : ""; cardEl.innerHTML = `
${gearMenu}
- ${urlStatusHtml} + ${connectionBadgesHtml} `; diff --git a/js/subscriptions.js b/js/subscriptions.js index 50ed39cb..68b42102 100644 --- a/js/subscriptions.js +++ b/js/subscriptions.js @@ -388,9 +388,26 @@ class SubscriptionsManager { const magnetCandidate = trimmedMagnet || legacyInfoHash; const playbackMagnet = magnetCandidate; const magnetProvided = magnetCandidate.length > 0; - const urlStatusHtml = trimmedUrl - ? window.app?.getUrlHealthPlaceholderMarkup?.() ?? "" + const magnetSupported = + window.app?.isMagnetUriSupported?.(magnetCandidate) ?? false; + const urlBadgeHtml = trimmedUrl + ? window.app?.getUrlHealthPlaceholderMarkup?.({ includeMargin: false }) ?? + "" : ""; + const torrentHealthBadgeHtml = + magnetProvided && magnetSupported + ? window.app?.getTorrentHealthBadgeMarkup?.({ + includeMargin: false, + }) ?? "" + : ""; + const connectionBadgesHtml = + urlBadgeHtml || torrentHealthBadgeHtml + ? ` +
+ ${urlBadgeHtml}${torrentHealthBadgeHtml} +
+ ` + : ""; const cardHtml = `
-
- - Streamable? - - - 🟦 - -

${gearMenu}

- ${urlStatusHtml} + ${connectionBadgesHtml}
`;