mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
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:
@@ -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}
|
||||
|
||||
@@ -332,8 +332,6 @@
|
||||
draftReviewStorage.addComment(draftId, { body, location });
|
||||
} catch (error) {
|
||||
console.error("Creating code comment failed", error);
|
||||
} finally {
|
||||
await loadPatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user