mirror of
https://github.com/block/buzz.git
synced 2026-11-04 00:12:02 +00:00
fix(desktop): refine thread panel reply layout
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { buildMainTimelineEntries } from "./threadPanel.ts";
|
||||
import {
|
||||
buildMainTimelineEntries,
|
||||
buildThreadPanelData,
|
||||
} from "./threadPanel.ts";
|
||||
|
||||
function message(overrides) {
|
||||
return {
|
||||
@@ -56,3 +59,66 @@ test("buildMainTimelineEntries includes broadcast replies", () => {
|
||||
["root", "broadcast-reply"],
|
||||
);
|
||||
});
|
||||
|
||||
test("buildThreadPanelData keeps direct replies flat", () => {
|
||||
const root = message({ id: "root", createdAt: 1 });
|
||||
const reply = message({
|
||||
id: "reply",
|
||||
createdAt: 2,
|
||||
parentId: "root",
|
||||
rootId: "root",
|
||||
depth: 1,
|
||||
tags: [["e", "root", "", "reply"]],
|
||||
});
|
||||
|
||||
const panel = buildThreadPanelData([root, reply], "root", null, new Set());
|
||||
|
||||
assert.deepEqual(
|
||||
panel.visibleReplies.map((entry) => ({
|
||||
id: entry.message.id,
|
||||
depth: entry.message.depth,
|
||||
})),
|
||||
[{ id: "reply", depth: 0 }],
|
||||
);
|
||||
});
|
||||
|
||||
test("buildThreadPanelData indents expanded subthread replies", () => {
|
||||
const root = message({ id: "root", createdAt: 1 });
|
||||
const reply = message({
|
||||
id: "reply",
|
||||
createdAt: 2,
|
||||
parentId: "root",
|
||||
rootId: "root",
|
||||
depth: 1,
|
||||
tags: [["e", "root", "", "reply"]],
|
||||
});
|
||||
const nestedReply = message({
|
||||
id: "nested-reply",
|
||||
createdAt: 3,
|
||||
parentId: "reply",
|
||||
rootId: "root",
|
||||
depth: 2,
|
||||
tags: [
|
||||
["e", "root", "", "root"],
|
||||
["e", "reply", "", "reply"],
|
||||
],
|
||||
});
|
||||
|
||||
const panel = buildThreadPanelData(
|
||||
[root, reply, nestedReply],
|
||||
"root",
|
||||
null,
|
||||
new Set(["reply"]),
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
panel.visibleReplies.map((entry) => ({
|
||||
id: entry.message.id,
|
||||
depth: entry.message.depth,
|
||||
})),
|
||||
[
|
||||
{ id: "reply", depth: 0 },
|
||||
{ id: "nested-reply", depth: 1 },
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -207,7 +207,7 @@ function buildVisibleThreadReplies(params: {
|
||||
appendExpandedReplies({
|
||||
entries,
|
||||
parentId: openThreadHeadId,
|
||||
depth: 1,
|
||||
depth: 0,
|
||||
directChildrenByParentId,
|
||||
descendantStatsByMessageId,
|
||||
expandedReplyIds,
|
||||
|
||||
@@ -255,7 +255,7 @@ export const MessageRow = React.memo(
|
||||
<article
|
||||
className={cn(
|
||||
"group/message rounded-2xl px-2 py-1 transition-colors",
|
||||
isThreadReplyLayout ? "space-y-1" : "flex items-start gap-2.5",
|
||||
isThreadReplyLayout ? "space-y-0" : "flex items-start gap-2.5",
|
||||
highlighted ? "bg-primary/10 ring-1 ring-primary/30" : "",
|
||||
)}
|
||||
data-message-id={message.id}
|
||||
@@ -298,7 +298,9 @@ export const MessageRow = React.memo(
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="min-w-0 space-y-0.5">{messageBodyNode}</div>
|
||||
<div className="-mt-0.5 min-w-0 space-y-0.5 pl-[26px]">
|
||||
{messageBodyNode}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user