mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-28 08:22:24 +00:00
Fix comment modal current video handling
This commit is contained in:
1 parent
1f47548bb8
commit
aee8bd44ae
2 files changed
+57
-2
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in new issue
Block a user