annotation: reset comment id if autosave is cancelled

problem:
User A writes Comment 1 and saves
User A replies to himself, write something, click away to autosave, Cancel
user A modifies Comment 1 and OK - comment disappears, although it is there, seen after reload, but without modification.

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I5d83936f26939b5a05a0ce3099c01923a55c9606
This commit is contained in:
Pranam Lashkari 2023-11-20 22:33:59 +05:30 committed by Rashesh Padia
parent 6a32adcfe8
commit 3c1ac04b0e
2 changed files with 4 additions and 3 deletions

View file

@ -1159,9 +1159,8 @@ export class CommentSection extends CanvasSectionObject {
}
if (action === 'Add') {
if (app.view.commentAutoSave) {
// preserve the id of the root comment and use it when reply button is clicked
if (app.view.commentAutoSave.sectionProperties.data.reply)
app.view.commentAutoSave.sectionProperties.data.oldId = app.view.commentAutoSave.sectionProperties.data.id;
// preserve original Id, can be used in case of reply to find parent comment, or revert the id in case comment insertion is cancelled
app.view.commentAutoSave.sectionProperties.data.oldId = app.view.commentAutoSave.sectionProperties.data.id;
app.view.commentAutoSave.sectionProperties.data.id = obj.comment.id;
app.view.commentAutoSave.sectionProperties.autoSave.innerText = _('Autosaved') ;
app.view.commentAutoSave = null;

View file

@ -826,6 +826,8 @@ export class Comment extends CanvasSectionObject {
return;
if (app.view.commentAutoAdded) {
this.sectionProperties.commentListSection.remove(this.sectionProperties.data.id);
app.view.commentAutoAdded = false;
this.sectionProperties.data.id = this.sectionProperties.data.oldId;
if (this.sectionProperties.commentListSection.sectionProperties.selectedComment.sectionProperties.container.classList.contains('reply-annotation-container')) {
this.show();
return;