more consistent post jumping behavior on submissions

pull/4/head
Blake DeMarcy 2017-04-21 15:27:24 -05:00
parent 8b44d51181
commit b19215a3b6
1 changed files with 17 additions and 4 deletions

View File

@ -1242,7 +1242,7 @@ class App(object):
if not self.prefs["integrate_external_editor"]: if not self.prefs["integrate_external_editor"]:
body = self.overthrow_ext_edit(init_body) body = self.overthrow_ext_edit(init_body)
if not body: if not body or re.search("^>>[0-9]+$", body):
return self.temp_footer_message("EMPTY POST DISCARDED") return self.temp_footer_message("EMPTY POST DISCARDED")
params = {"body": body} params = {"body": body}
@ -1262,7 +1262,16 @@ class App(object):
params.update({"title": title}) params.update({"title": title})
network.request(endpoint, **params) network.request(endpoint, **params)
return self.refresh() self.refresh()
if edit:
self.goto_post(edit["post_id"])
elif self.mode == "thread":
self.goto_post(self.thread["reply_count"])
else:
self.box.keypress(self.loop.screen_size, "t")
return
if self.mode == "index": if self.mode == "index":
self.set_header('Composing "{}"', title) self.set_header('Composing "{}"', title)
@ -1515,8 +1524,12 @@ class ExternalEditor(urwid.Terminal):
self.params.update({"body": body}) self.params.update({"body": body})
network.request(self.endpoint, **self.params) network.request(self.endpoint, **self.params)
app.refresh() app.refresh()
if app.mode == "thread": if self.endpoint == "edit_post":
app.goto_post(self.params["post_id"])
elif app.mode == "thread":
app.goto_post(app.thread["reply_count"]) app.goto_post(app.thread["reply_count"])
else: else:
app.box.keypress(app.loop.screen_size, "t") app.box.keypress(app.loop.screen_size, "t")
else: else:
@ -1569,7 +1582,7 @@ class ExternalEditor(urwid.Terminal):
if self.term_modes.lfnl and key == "\x0d": if self.term_modes.lfnl and key == "\x0d":
key += "\x0a" key += "\x0a"
os.write(self.master, key.encode('utf8')) os.write(self.master, key.encode("utf8"))
def __del__(self): def __del__(self):