From 108ef374566e7e4dfe6c126675e51542cf601276 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Mon, 27 Oct 2025 13:24:01 -0400 Subject: [PATCH] Restore similar content playback handling --- js/ui/ModalManager.js | 57 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/js/ui/ModalManager.js b/js/ui/ModalManager.js index eaad078e..ccc751d6 100644 --- a/js/ui/ModalManager.js +++ b/js/ui/ModalManager.js @@ -415,11 +415,58 @@ export default class ModalManager { return; } - app.openVideoModal({ - video: selectedVideo, - triggerElement: triggerCandidate || null, - source: detail?.source || "modal", - }); + const playbackOptions = { + trigger: triggerCandidate || null, + }; + + const rawUrl = + typeof selectedVideo.url === "string" ? selectedVideo.url.trim() : ""; + if (rawUrl) { + playbackOptions.url = rawUrl; + } + + const rawMagnet = + typeof selectedVideo.magnet === "string" + ? selectedVideo.magnet.trim() + : ""; + if (rawMagnet) { + playbackOptions.magnet = rawMagnet; + } + + const hasPlayById = typeof app.playVideoByEventId === "function"; + const hasFallbackPlayback = + typeof app.playVideoWithFallback === "function"; + + const selectedId = + typeof selectedVideo.id === "string" ? selectedVideo.id : ""; + + if (selectedId && hasPlayById) { + Promise.resolve(app.playVideoByEventId(selectedId, playbackOptions)).catch( + (error) => { + devLogger.error( + "[ModalManager] Failed to play selected similar video:", + error, + ); + }, + ); + return; + } + + if (!hasFallbackPlayback) { + devLogger.warn( + "[ModalManager] Unable to start playback for similar video; no playback handler is available.", + ); + return; + } + + Promise.resolve(app.playVideoWithFallback(playbackOptions)).catch( + (error) => { + devLogger.error( + "[ModalManager] Failed to start playback for similar video:", + error, + ); + }, + ); }; this.videoModal.addEventListener( "similar:select",