Fix comment modal current video handling

This commit is contained in:
thePR0M3TH3AN committed 2025-10-29 22:38:49 -04:00
1 parent 1f47548bb8
commit aee8bd44ae
2 files changed
+57 -2

No files matched your search

+1 -2
View File
@@ -121,6 +121,7 @@ export default class VideoModalCommentController {
return;
}
this.dispose({ resetUi: false });
this.currentVideo = video;
this.videoModal.setCommentSectionCallbacks?.({
@@ -132,8 +133,6 @@ export default class VideoModalCommentController {
return;
}
this.dispose({ resetUi: false });
this.videoModal.hideCommentsDisabledMessage?.();
if (video.enableComments === false) {
+56
View File
@@ -176,6 +176,62 @@ test("VideoModal comment composer updates messaging and dispatches events", asyn
assert.strictEqual(submitDetail.triggerElement, modal.commentsSubmitButton);
});
test(
"VideoModalCommentController load preserves current video for submissions",
async () => {
const publishCalls = [];
const controller = new VideoModalCommentController({
commentThreadService: {
setCallbacks: () => {},
teardown: () => {},
defaultLimit: 10,
loadThread: () => Promise.resolve(),
processIncomingEvent: () => {},
},
videoModal: {
setCommentSectionCallbacks: () => {},
hideCommentsDisabledMessage: () => {},
showCommentsDisabledMessage: () => {},
setCommentsVisibility: () => {},
clearComments: () => {},
resetCommentComposer: () => {},
setCommentStatus: () => {},
setCommentComposerState: () => {},
},
auth: {
isLoggedIn: () => true,
},
services: {
publishComment: async (payload) => {
publishCalls.push(payload);
return { ok: true, event: { id: "comment", tags: [] } };
},
},
utils: {
normalizeHexPubkey: (value) => value,
},
});
const video = {
id: "video123",
pubkey: "AUTHORPK",
enableComments: true,
kind: 30078,
};
controller.load(video);
controller.submit({ text: "Nice" });
await controller.modalCommentPublishPromise;
assert.equal(publishCalls.length, 1, "publishComment should be called once");
const payload = publishCalls[0];
assert.equal(payload.videoEventId, "video123");
assert.equal(payload.videoAuthorPubkey, "AUTHORPK");
},
);
test(
"VideoModalCommentController publishes comment using event id fallback",
async () => {