desktop: Stop reloading the patch on draft edits

Draft review comments are local, so editing them doesn't need the whole
patch view to load again.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-20 19:32:16 +01:00
parent f9f9009aea
commit 8a8d457c32
5 changed files with 6 additions and 18 deletions
+4 -10
View File
@@ -24,7 +24,6 @@
// The protocol keeps one review per author per revision and silently
// ignores a second one, which would discard this draft without a trace.
alreadyReviewed?: boolean;
onChange: () => Promise<void>;
onPublish: (revisionId: string) => Promise<void>;
onCancel: () => void;
// Scroll the diff to a pending comment. Absent where there is no diff to
@@ -37,7 +36,6 @@
filesChecked,
filesTotal,
alreadyReviewed = false,
onChange,
onPublish,
onCancel,
onSelectComment,
@@ -148,18 +146,16 @@
editingCommentId = undefined;
editBody = "";
}
async function saveEdit(commentId: string) {
function saveEdit(commentId: string) {
draftReviewStorage.updateComment(draftReview.id, commentId, {
body: editBody,
});
editingCommentId = undefined;
editBody = "";
await onChange();
}
async function deleteComment(commentId: string) {
function deleteComment(commentId: string) {
draftReviewStorage.deleteComment(draftReview.id, commentId);
if (editingCommentId === commentId) cancelEdit();
await onChange();
}
let confirmDeleteId: string | undefined = $state();
@@ -168,7 +164,7 @@
if (confirmDeleteId === commentId) {
if (confirmDeleteTimer) clearTimeout(confirmDeleteTimer);
confirmDeleteId = undefined;
void deleteComment(commentId);
deleteComment(commentId);
} else {
confirmDeleteId = commentId;
if (confirmDeleteTimer) clearTimeout(confirmDeleteTimer);
@@ -188,13 +184,12 @@
);
const verdictColorClass = $derived(verdictBadge(verdict).variant);
async function persistSummary() {
function persistSummary() {
draftReviewStorage.update(draftReview.id, {
summary,
verdict,
labels: draftReview.labels,
});
await onChange();
}
let publishError: string | undefined = $state();
@@ -793,7 +788,6 @@
labels: draftReview.labels,
});
closeFocused();
void onChange();
}}>
<div class="verdict-check">
{#if verdict === option.value}
-2
View File
@@ -332,8 +332,6 @@
draftReviewStorage.addComment(draftId, { body, location });
} catch (error) {
console.error("Creating code comment failed", error);
} finally {
await loadPatch();
}
}
-2
View File
@@ -62,7 +62,6 @@ export function commentActions(ctx: CommentActionsContext): CommentActions {
if (!owner) return;
if (owner.kind === "draft") {
draftReviewStorage.updateComment(owner.draftId, commentId, { body });
await reload();
return;
}
await run(
@@ -90,7 +89,6 @@ export function commentActions(ctx: CommentActionsContext): CommentActions {
if (!owner) return;
if (owner.kind === "draft") {
draftReviewStorage.deleteComment(owner.draftId, commentId);
await reload();
return;
}
await run(
-2
View File
@@ -1559,7 +1559,6 @@
: undefined}
filesTotal={showingRevisionDiff ? fileProgress?.filesTotal : undefined}
alreadyReviewed={hasOwnPublishedReviewOnSelected}
onChange={loadPatch}
onPublish={async revisionId => {
await loadPatch();
const updatedRev = revisions.find(r => r.id === revisionId);
@@ -1579,7 +1578,6 @@
}}
onCancel={() => {
draftReviewStorage.delete(ownDraftReview.id);
void loadPatch();
}}
onSelectComment={currentReview
? // A published review page renders its own diff and none of this
@@ -66,7 +66,7 @@ describe("editComment", () => {
{ body: "new" },
);
expect(invoke).not.toHaveBeenCalled();
expect(reload).toHaveBeenCalledTimes(1);
expect(reload).not.toHaveBeenCalled();
});
test.each([
@@ -107,7 +107,7 @@ describe("deleteComment", () => {
"d",
);
expect(invoke).not.toHaveBeenCalled();
expect(reload).toHaveBeenCalledTimes(1);
expect(reload).not.toHaveBeenCalled();
});
test.each([