mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-31 18:02:27 +00:00
Fix comment address fallback when video tags missing
This commit is contained in:
1 parent
3445ef9059
commit
e704b93287
2 files changed
+75
-2
No files matched your search
@@ -144,7 +144,12 @@ export default class VideoModalCommentController {
|
||||
}
|
||||
|
||||
const videoEventId = normalizeString(video.id);
|
||||
const videoDefinitionAddress = buildVideoAddressPointer(video);
|
||||
let videoDefinitionAddress = buildVideoAddressPointer(video);
|
||||
if (!videoDefinitionAddress && this.modalCommentState.videoDefinitionAddress) {
|
||||
videoDefinitionAddress = normalizeString(
|
||||
this.modalCommentState.videoDefinitionAddress,
|
||||
);
|
||||
}
|
||||
const videoKind = normalizeKind(video.kind);
|
||||
const videoAuthorPubkey = normalizeString(video.pubkey);
|
||||
|
||||
@@ -544,7 +549,12 @@ export default class VideoModalCommentController {
|
||||
}
|
||||
|
||||
const videoEventId = normalizeString(video.id);
|
||||
const videoDefinitionAddress = buildVideoAddressPointer(video);
|
||||
let videoDefinitionAddress = buildVideoAddressPointer(video);
|
||||
if (!videoDefinitionAddress && this.modalCommentState.videoDefinitionAddress) {
|
||||
videoDefinitionAddress = normalizeString(
|
||||
this.modalCommentState.videoDefinitionAddress,
|
||||
);
|
||||
}
|
||||
const videoKind =
|
||||
this.modalCommentState.videoKind || normalizeKind(video.kind);
|
||||
const videoAuthorPubkey =
|
||||
|
||||
@@ -245,6 +245,69 @@ test(
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"VideoModalCommentController falls back to thread pointer when video tags are absent",
|
||||
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: "video456",
|
||||
pubkey: "AUTHORPK",
|
||||
enableComments: true,
|
||||
kind: 30078,
|
||||
// No tags provided; buildVideoAddressPointer should return an empty string.
|
||||
};
|
||||
|
||||
controller.load(video);
|
||||
controller.modalCommentState.videoDefinitionAddress =
|
||||
" 30078:AUTHORPK:video-root ";
|
||||
|
||||
controller.submit({ text: "Fallback pointer" });
|
||||
|
||||
await controller.modalCommentPublishPromise;
|
||||
|
||||
assert.equal(publishCalls.length, 1);
|
||||
const payload = publishCalls[0];
|
||||
assert.equal(
|
||||
payload.videoDefinitionAddress,
|
||||
"30078:AUTHORPK:video-root",
|
||||
"publish payload should reuse pointer from the loaded thread",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"VideoModalCommentController publishes comment using event id fallback",
|
||||
async () => {
|
||||
|
||||
Reference in new issue
Block a user