fix(embed): implement robust EmbedPlayerModal and guard resetTorrentStats

- Add `js/ui/components/EmbedPlayerModal.js` to implement the `VideoModal` interface for embed contexts (including `resetStats`).
- Update `js/ui/ModalManager.js` to detect embed mode and use `EmbedPlayerModal`.
- Clean up `js/embed.js` to remove local modal definition and add `postMessage` diagnostic logging.
- Update `js/app.js` `resetTorrentStats` log message and verify guard.
- Add unit tests for `EmbedPlayerModal` and `resetTorrentStats` logic.
- Add E2E reproduction script `tests/e2e/repro_issue.spec.ts`.
This commit is contained in:
google-labs-jules[bot] committed 2026-01-24 22:09:03 +00:00
1 parent d71d2812f4
commit 981fac785a
7 files changed
+379 -117

No files matched your search

+27 -19
View File
@@ -7,6 +7,7 @@ import { VideoModal } from "./components/VideoModal.js";
import { RevertModal } from "./components/RevertModal.js";
import { ShareNostrModal } from "./components/ShareNostrModal.js";
import { EmbedVideoModal } from "./components/EmbedVideoModal.js";
import { EmbedPlayerModal } from "./components/EmbedPlayerModal.js";
import initUploadModal from "./initUploadModal.js";
import initEditModal from "./initEditModal.js";
import initDeleteModal from "./initDeleteModal.js";
@@ -195,29 +196,36 @@ export default class ModalManager {
});
app.embedVideoModal = this.embedVideoModal;
const isEmbedMode = typeof window !== "undefined" && window.location.pathname.endsWith("/embed.html");
this.videoModal =
(typeof this.ui.videoModal === "function"
? this.ui.videoModal({ app })
: this.ui.videoModal) ||
new VideoModal({
removeTrackingScripts,
setGlobalModalState,
document: doc,
logger: {
log: (message, ...args) => app.log(message, ...args),
},
mediaLoader: app.mediaLoader,
assets: {
fallbackThumbnailSrc: this.assets.fallbackThumbnailSrc,
},
state: {
loadedThumbnails: app.loadedThumbnails,
},
helpers: {
safeEncodeNpub: (pubkey) => app.safeEncodeNpub(pubkey),
formatShortNpub: (value) => formatShortNpub(value),
},
});
(isEmbedMode
? new EmbedPlayerModal({
document: doc,
logger: { log: (...a) => app.log(...a) },
})
: new VideoModal({
removeTrackingScripts,
setGlobalModalState,
document: doc,
logger: {
log: (message, ...args) => app.log(message, ...args),
},
mediaLoader: app.mediaLoader,
assets: {
fallbackThumbnailSrc: this.assets.fallbackThumbnailSrc,
},
state: {
loadedThumbnails: app.loadedThumbnails,
},
helpers: {
safeEncodeNpub: (pubkey) => app.safeEncodeNpub(pubkey),
formatShortNpub: (value) => formatShortNpub(value),
},
}));
if (
this.videoModal &&