From ca7c5b8a7be8e4716b2029344539a137c2ee75f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Fri, 20 Nov 2026 19:10:53 +0100 Subject: [PATCH] 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. --- desktop/src/components/IssueDescription.svelte | 18 +++++++++++++++++- desktop/src/components/ReviewPage.svelte | 6 ++++++ desktop/src/views/repo/Issue.svelte | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/desktop/src/components/IssueDescription.svelte b/desktop/src/components/IssueDescription.svelte index 38b140352..128cc919f 100644 --- a/desktop/src/components/IssueDescription.svelte +++ b/desktop/src/components/IssueDescription.svelte @@ -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; reactOnComment: (authors: Author[], reaction: string) => Promise; } @@ -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); @@ -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}> {/if} diff --git a/desktop/src/components/ReviewPage.svelte b/desktop/src/components/ReviewPage.svelte index 432bd0820..dcc376e9c 100644 --- a/desktop/src/components/ReviewPage.svelte +++ b/desktop/src/components/ReviewPage.svelte @@ -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} /> diff --git a/desktop/src/views/repo/Issue.svelte b/desktop/src/views/repo/Issue.svelte index 060923e65..4fc383f34 100644 --- a/desktop/src/views/repo/Issue.svelte +++ b/desktop/src/views/repo/Issue.svelte @@ -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)} />