in src/desktop/gitlab/gitlab_service.ts [573:607]
async updateNoteBody(
noteGqlId: string,
body: string,
originalBody: string,
mr: RestMr,
): Promise<void> {
await this.validateVersion('MR Discussions', REQUIRED_VERSIONS.MR_DISCUSSIONS);
const latestNote = await this.#getMrNote(mr, getRestIdFromGraphQLId(noteGqlId));
// This check is the best workaround we can do in the lack of optimistic locking
// Issue to make this check in the GitLab instance: https://gitlab.com/gitlab-org/gitlab/-/issues/323808
if (latestNote.body !== originalBody) {
throw new UserFriendlyError(
`This comment changed after you last viewed it, and can't be edited.
Your new comment is NOT lost. To retrieve it, edit the comment again and copy your comment text,
then update the original comment by opening the sidebar and running the
"GitLab: Refresh sidebar" command.`,
new Error(
`You last saw:\n"${originalBody}"\nbut the latest version is:\n"${latestNote.body}"`,
),
);
}
try {
await this.#apiClient.graphqlRequest(updateNoteBodyMutation, {
noteId: noteGqlId,
body,
});
} catch (e) {
throw new UserFriendlyError(
`Couldn't update the comment when calling the API.
Your draft hasn't been lost. To see it, edit the comment.
For more information, review the extension logs.`,
e,
);
}
}