From b5d7f34ea6584ca8d5c97fdd68a4a4a550ca4f1e Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Wed, 14 Aug 2019 12:40:46 +0200 Subject: [PATCH] Remove the comment from the post after undo 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jan-pona-mute.py b/jan-pona-mute.py index dfe13cd..332cf17 100755 --- a/jan-pona-mute.py +++ b/jan-pona-mute.py @@ -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]) -- 2.25.1