desktop: Edit the description from its latest version

Editing or ticking a task while the "has been edited" banner showed saved
the older text, which reverted the edit the user hadn't seen yet.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-20 19:32:17 +01:00
parent a7c4ded104
commit ca7c5b8a7b
3 changed files with 25 additions and 1 deletions
+17 -1
View File
@@ -19,6 +19,9 @@
reactions: Reaction[];
currentUserNid?: string;
allowedToEdit: boolean;
// Whether `body` is older than the latest edit, which `showLatest` shows.
stale: boolean;
showLatest: () => void;
editComment: (body: string, embeds: Embed[]) => Promise<void>;
reactOnComment: (authors: Author[], reaction: string) => Promise<void>;
}
@@ -30,10 +33,19 @@
reactions,
currentUserNid,
allowedToEdit,
stale,
showLatest,
editComment,
reactOnComment,
}: Props = $props();
// An edit starts from the latest text, so that it can't undo an edit the
// user hasn't seen. A ticked task in older text only brings up the latest.
function edit() {
if (stale) showLatest();
editing = true;
}
let editing = $state(false);
</script>
@@ -109,6 +121,10 @@
content={body}
toggleTaskItem={allowedToEdit
? async content => {
if (stale) {
showLatest();
return;
}
await editComment(content, embeds);
}
: undefined} />
@@ -133,7 +149,7 @@
type="button"
class="body-action"
title="Edit description"
onclick={() => (editing = true)}>
onclick={edit}>
<Icon name="edit" />
</button>
{/if}
+6
View File
@@ -999,6 +999,12 @@
content={pinnedSummary.current}
toggleTaskItem={isOwnPublishedReview
? async content => {
// A ticked task in older text only brings up the latest,
// so that saving it can't undo an edit the user hasn't seen.
if (pinnedSummary.stale) {
pinnedSummary.apply();
return;
}
await saveSummary(content, review.embeds);
}
: undefined} />
+2
View File
@@ -406,6 +406,8 @@
reactions={body.reactions}
currentUserNid={config.publicKey}
allowedToEdit={!!canEditIssue}
stale={description.stale}
showLatest={() => description.apply()}
editComment={(text, embeds) => editComment(body.id, text, embeds)}
reactOnComment={(authors, reaction) =>
reactOnComment(body.id, authors, reaction)} />