mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
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:
@@ -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}
|
||||
|
||||
@@ -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} />
|
||||
|
||||
@@ -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)} />
|
||||
|
||||
Reference in New Issue
Block a user