fix(more-menu): resolve modal ⋯ video so Event Details + Popularity work (#31)

The video modal's ⋯ trigger declares its context via `data-more-dropdown="modal"`,
but attachMoreMenuHandlers read only `data-context`, so it defaulted to "card",
skipped the modal video resolution, and opened the popover with a null video. The
panel is built from that video, so every menu item got an empty data-event-id and
both Event Details and Popularity reported "No video selected."

- Read context from `data-more-dropdown` as well as `data-context`.
- Modal branch falls back to the modal's `activeVideo` when getCurrentVideo() is
  null (deep-link opens don't set the playback service's currentVideo).
- Defense-in-depth: handleEventDetailsAction resolves the video from
  app.videosMap.get(eventId); view-stats resolves via a new getVideoByEventId
  callback instead of a risky `|| currentVideo` that could show the wrong stats.
- Regression tests in tests/more-menu-controller.test.mjs.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.8 committed 2026-06-24 18:48:49 -04:00
1 parent 63dcb5f6ed
commit 1c256808ff
4 files changed
+160 -8

No files matched your search

+11 -2
View File
@@ -675,6 +675,10 @@ export default class ApplicationBootstrap {
designSystem: app.designSystemContext,
callbacks: {
getCurrentVideo: () => app.currentVideo,
getVideoByEventId: (eventId) =>
eventId && app.videosMap instanceof Map
? app.videosMap.get(eventId) || null
: null,
getCurrentUserNpub: () => app.getCurrentUserNpub(),
getCurrentUserPubkey: () => app.pubkey,
canCurrentUserManageBlacklist: () =>
@@ -700,9 +704,14 @@ export default class ApplicationBootstrap {
app.showError?.("Event details are unavailable.");
return Promise.resolve();
}
const video = payload?.video || null;
// Card popovers sometimes don't carry the video object on context, so
// resolve it from the menu item's eventId as a fallback (the object the
// grid already holds). This is what made the button silently no-op.
let video = payload?.video || null;
if (!video && payload?.eventId && app.videosMap instanceof Map) {
video = app.videosMap.get(payload.eventId) || null;
}
if (!video) {
// Don't fail silently — this is the bug the ⋯ "Event Details" button hit.
app.showError?.("No video selected for event details.");
return Promise.resolve();
}