Remove the comment from the post after undo
authorAlex Schroeder <alex@gnu.org>
Wed, 14 Aug 2019 10:40:46 +0000 (12:40 +0200)
committerAlex Schroeder <alex@gnu.org>
Wed, 14 Aug 2019 10:40:46 +0000 (12:40 +0200)
The undo case (delete comment x from y) is now handled like the normal
case (delete comment z) in that we update the comments of the post
such as to remove the deleted comment. This fixes the display using
the comments command.

jan-pona-mute.py

index dfe13cdb92e4025c67e37213af37f4e9e4e43b03..332cf17bcb9573a147d33a86607d3caac7166200 100755 (executable)
@@ -427,13 +427,16 @@ Use the 'edit' command to edit notes."""
         words = line.strip().split()
         if words:
             if words[0] == "comment":
-                if self.post == None:
-                    print("Use the 'show' command to show a post, first.")
-                    return
                 if len(words) == 4:
-                    self.post_cache[words[3]].delete_comment(words[1])
+                    post = self.post_cache[words[3]]
+                    post.delete_comment(words[1])
+                    comments = [c.id for c in post.comments if c.id != id]
+                    post.comments = diaspy.models.Comments(comments)
                     print("Comment deleted.")
                     return
+                if self.post == None:
+                    print("Use the 'show' command to show a post, first.")
+                    return
                 if len(words) == 2:
                     try:
                         n = int(words[1])