Merge pull request #1055 from PR0M3TH3AN/codex/update-comment-handling-for-login-required-state

Handle login-required comment visibility
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-02 10:33:08 -05:00
commit b14a7e60a0
3 files changed
+69

No files matched your search

+1
View File
@@ -969,6 +969,7 @@ export class VideoModal {
if (normalizedReason === "login-required") {
this.setCommentHintText("Log in to add a comment.");
this.setCommentStatus("");
this.setCommentsVisibility(true);
} else if (normalizedReason === "submitting") {
this.setCommentHintText(this.commentComposerDefaultHint);
this.setCommentStatus("Posting comment…");
+2
View File
@@ -341,6 +341,8 @@ export default class VideoModalCommentController {
disabled: true,
reason: "login-required",
});
this.videoModal.setCommentsVisibility?.(true);
this.videoModal.setCommentStatus?.("");
return;
}
+66
View File
@@ -120,6 +120,72 @@ test("VideoModal comment section toggles visibility and renders hydrated comment
assert.equal(modal.commentsList.getAttribute("data-empty"), null);
});
test(
"Unauthenticated users can read comments while the composer stays disabled",
async (t) => {
const { document, modal, cleanup } = await setupModal();
t.after(cleanup);
const controller = new VideoModalCommentController({
commentThreadService: {
defaultLimit: 2,
setCallbacks: () => {},
teardown: () => {},
loadThread: () => Promise.resolve(),
processIncomingEvent: () => {},
},
videoModal: modal,
auth: {
isLoggedIn: () => false,
},
});
controller.load({ id: "video-login-required", enableComments: true });
await Promise.resolve();
controller.handleCommentThreadReady({
videoEventId: "video-login-required",
parentCommentId: null,
commentsById: new Map([
[
"guest-comment",
createCommentEvent({
id: "guest-comment",
pubkey: "pk-guest",
content: "Looking forward to more uploads",
createdAt: 1700000010,
}),
],
]),
childrenByParent: new Map([[null, ["guest-comment"]]]),
profiles: new Map([["pk-guest", { name: "Guest" }]]),
});
const commentsRoot = document.querySelector("[data-comments-root]");
assert.equal(commentsRoot.hasAttribute("hidden"), false);
assert.equal(commentsRoot.classList.contains("hidden"), false);
const renderedComments = Array.from(
modal.commentsList.querySelectorAll("[data-comment-id]") || [],
);
assert.equal(renderedComments.length, 1);
assert.equal(renderedComments[0].dataset.commentId, "guest-comment");
assert.equal(modal.commentComposerState.reason, "login-required");
assert.equal(modal.commentsInput?.disabled, true);
assert.equal(modal.commentsSubmitButton?.disabled, true);
const disabledPlaceholder = document.querySelector(
"[data-comments-disabled-placeholder]",
);
assert.equal(disabledPlaceholder.hasAttribute("hidden"), true);
assert.equal(
disabledPlaceholder.textContent.trim(),
"Comments have been turned off for this video.",
);
},
);
test(
"VideoModalCommentController attaches profiles using normalized pubkeys",
async () => {