From 5463677237bd92e298aeff4b9c1f9450a7f433c7 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 9 Oct 2025 19:59:00 -0400 Subject: [PATCH 1/2] Fix video modal rehydration after back navigation --- js/app.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index c39c6bf9..80bf9828 100644 --- a/js/app.js +++ b/js/app.js @@ -1313,9 +1313,25 @@ class Application { const existingVideoElement = getVideoElement(); if (existingRoot && existingRoot.isConnected) { - if (ensureVideoElement && !existingVideoElement) { - throw new Error("Video modal video element is not ready."); + if (!existingVideoElement && ensureVideoElement) { + if (typeof this.videoModal.load === "function") { + await this.videoModal.load(); + } + + const rehydratedRoot = getRoot(); + const rehydratedVideoElement = getVideoElement(); + + if (!rehydratedVideoElement) { + throw new Error("Video modal video element is not ready."); + } + + this.modalVideo = rehydratedVideoElement; + return { + root: rehydratedRoot || existingRoot, + videoElement: rehydratedVideoElement, + }; } + if (existingVideoElement) { this.modalVideo = existingVideoElement; } From d58d41118051e3e54adc66d84409fa75ea4140ad Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 9 Oct 2025 20:09:58 -0400 Subject: [PATCH 2/2] Ensure video modal rehydrates when video element is missing --- js/ui/components/VideoModal.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/js/ui/components/VideoModal.js b/js/ui/components/VideoModal.js index 089c8062..a01036b7 100644 --- a/js/ui/components/VideoModal.js +++ b/js/ui/components/VideoModal.js @@ -127,8 +127,28 @@ export class VideoModal { } async load() { - if (this.loaded && this.playerModal && this.playerModal.isConnected) { - return this.playerModal; + if (this.loaded) { + const root = this.playerModal; + const rootConnected = root && root.isConnected; + if (rootConnected) { + const video = this.modalVideo; + const videoConnected = video && video.isConnected; + if (!videoConnected) { + const existingVideo = root.querySelector("#modalVideo"); + if (existingVideo) { + this.hydrate(root); + if (this.modalVideo && this.modalVideo.isConnected) { + return this.playerModal; + } + } + this.loaded = false; + } else { + return this.playerModal; + } + } else { + this.loaded = false; + this.playerModal = null; + } } const existing = this.document.getElementById("playerModal");