Make sure to discard a draft whenever we're saving.

Release-Notes: fixes deletion of patchset comment right before saving.
Google-Bug-Id: b/309970044, b/309533366
Change-Id: I420fd0193f4911aca85b26989ebfa60f784f90d7
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index 7a8779d..459ff0f 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -1452,13 +1452,19 @@
     await this.save();
   }
 
-  convertToCommentInput(): CommentInput | undefined {
+  async convertToCommentInputAndOrDiscard(): Promise<CommentInput | undefined> {
     if (!this.somethingToSave() || !this.comment) return;
-    return convertToCommentInput({
-      ...this.comment,
-      message: this.messageText.trimEnd(),
-      unresolved: this.unresolved,
-    });
+    const messageToSave = this.messageText.trimEnd();
+    if (messageToSave === '') {
+      await this.getCommentsModel().discardDraft(id(this.comment));
+      return undefined;
+    } else {
+      return convertToCommentInput({
+        ...this.comment,
+        message: this.messageText.trimEnd(),
+        unresolved: this.unresolved,
+      });
+    }
   }
 
   async save() {