check for empty post before asking for confirmation
before this change, BBJ would give the big "You are posting anonymously!" warning even if the post body was empty (say, because you accidentally started a post and closed the editor immediately). only after confirming that you _really_ wanted to post anonymously would it notice that, hey, the post body is empty and discard the post. it makes more sense to do the checks the other way around.master
parent
92bdd7b660
commit
315a249ef6
|
@ -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,12 +2032,7 @@ 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)
|
||||
|
||||
if body and not re.search("^>>[0-9]+$", body):
|
||||
# ok; do the post
|
||||
self.params.update({"body": body})
|
||||
app.network.request(self.endpoint, **self.params)
|
||||
if self.endpoint == "edit_post":
|
||||
|
@ -2039,8 +2046,6 @@ class ExternalEditor(urwid.Terminal):
|
|||
else:
|
||||
app.last_pos = None
|
||||
app.index()
|
||||
else:
|
||||
app.temp_footer_message("EMPTY POST DISCARDED")
|
||||
|
||||
|
||||
def keypress(self, size, key):
|
||||
|
|
Loading…
Reference in New Issue