diff --git a/clients/urwid/main.py b/clients/urwid/main.py index 85077f9..e9c6e59 100644 --- a/clients/urwid/main.py +++ b/clients/urwid/main.py @@ -1982,6 +1982,18 @@ class ExternalEditor(urwid.Terminal): def exterminate(self, *_, anon_confirmed=False): + # close the editor and grab the post body + app.close_editor() + with open(self.path) as _: + body = _.read().strip() + os.remove(self.path) + + # make sure its not empty + if not body or re.search("^>>[0-9]+$", body): + app.temp_footer_message("EMPTY POST DISCARDED") + return + + # are we anonymous? check if the user wants to log in first if app.prefs["confirm_anon"] \ and not anon_confirmed \ and app.network.user["user_name"] == "anonymous": @@ -2020,27 +2032,20 @@ class ExternalEditor(urwid.Terminal): log_in(True) app.loop.start() - app.close_editor() - with open(self.path) as _: - body = _.read().strip() - os.remove(self.path) + # ok; do the post + self.params.update({"body": body}) + app.network.request(self.endpoint, **self.params) + if self.endpoint == "edit_post": + app.refresh() + app.goto_post(self.params["post_id"]) - if body and not re.search("^>>[0-9]+$", body): - self.params.update({"body": body}) - app.network.request(self.endpoint, **self.params) - if self.endpoint == "edit_post": - app.refresh() - app.goto_post(self.params["post_id"]) + elif app.mode == "thread": + app.refresh() + app.goto_post(app.thread["reply_count"]) - elif app.mode == "thread": - app.refresh() - app.goto_post(app.thread["reply_count"]) - - else: - app.last_pos = None - app.index() else: - app.temp_footer_message("EMPTY POST DISCARDED") + app.last_pos = None + app.index() def keypress(self, size, key):