mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-01 02:12:26 +00:00
Merge pull request #393 from PR0M3TH3AN/codex/fix-video-modal-initialization-issue
Fix video modal rehydration after back navigation
This commit is contained in:
2 files changed
+40
-4
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user