mirror of
https://github.com/block/buzz.git
synced 2026-10-30 22:11:36 +00:00
Reject mismatched reply route roots
Keep malformed reply intent non-actionable even when the selected reply and its actual thread root are already loaded. Co-authored-by: Rivet <a08d9a8418c7ff03afe19964724c8fd87bf1776ab9e9b9cafb8cc920edd02a6e@buzz.block.builderlab.xyz> Signed-off-by: Rivet <a08d9a8418c7ff03afe19964724c8fd87bf1776ab9e9b9cafb8cc920edd02a6e@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -48,7 +48,7 @@ test("top-level target with an explicit threadRootId opens its thread panel", ()
|
||||
});
|
||||
});
|
||||
|
||||
test("reply target opens the thread scrolled to the reply", () => {
|
||||
test("reply target without threadRootId opens the derived thread", () => {
|
||||
const root = makeMessage({ id: "root" });
|
||||
const reply = makeMessage({
|
||||
id: "reply",
|
||||
@@ -65,6 +65,40 @@ test("reply target opens the thread scrolled to the reply", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("reply target with its derived threadRootId opens the thread", () => {
|
||||
const root = makeMessage({ id: "root" });
|
||||
const reply = makeMessage({
|
||||
id: "reply",
|
||||
parentId: "root",
|
||||
rootId: "root",
|
||||
depth: 1,
|
||||
});
|
||||
assert.deepEqual(
|
||||
getRouteTargetPanelAction(reply, root.id, byId(root, reply)),
|
||||
{
|
||||
kind: "open-thread",
|
||||
expandedReplyIds: new Set(),
|
||||
replyTargetId: "root",
|
||||
scrollTargetId: "reply",
|
||||
threadHeadId: "root",
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("reply target with a mismatched threadRootId does not open the loaded derived thread", () => {
|
||||
const root = makeMessage({ id: "root" });
|
||||
const reply = makeMessage({
|
||||
id: "reply",
|
||||
parentId: "root",
|
||||
rootId: "root",
|
||||
depth: 1,
|
||||
});
|
||||
assert.deepEqual(
|
||||
getRouteTargetPanelAction(reply, "unrelated-root", byId(root, reply)),
|
||||
{ kind: "none" },
|
||||
);
|
||||
});
|
||||
|
||||
test("nested reply target expands its intermediate ancestors", () => {
|
||||
const root = makeMessage({ id: "root" });
|
||||
const mid = makeMessage({
|
||||
|
||||
@@ -84,6 +84,11 @@ export function getRouteTargetPanelAction(
|
||||
};
|
||||
}
|
||||
|
||||
const derivedRootId = targetMessage.rootId ?? targetMessage.parentId;
|
||||
if (targetThreadRootId !== null && targetThreadRootId !== derivedRootId) {
|
||||
return { kind: "none" };
|
||||
}
|
||||
|
||||
if (isBroadcastReply(targetMessage.tags ?? [])) {
|
||||
return { kind: "none" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user