restrict on_post actions when the composer is open

pull/4/head
Blake DeMarcy 2017-04-15 05:28:05 -05:00
parent 2a2a9e8762
commit dd90247d8c
1 changed files with 11 additions and 5 deletions

View File

@ -482,16 +482,19 @@ class App(object):
def on_post(self, button, message): def on_post(self, button, message):
quotes = self.get_quotes(message) quotes = self.get_quotes(message)
author = self.usermap[message["author"]] author = self.usermap[message["author"]]
buttons = [ buttons = []
urwid.Button("Reply", self.reply, message),
] if not self.window_split:
buttons.append(urwid.Button("Reply", self.reply, message))
if quotes and message["post_id"] != 0: if quotes and message["post_id"] != 0:
buttons.insert(1, urwid.Button( buttons.append(urwid.Button(
"View %sQuote" % ("a " if len(quotes) != 1 else ""), "View %sQuote" % ("a " if len(quotes) != 1 else ""),
self.quote_view_menu, quotes)) self.quote_view_menu, quotes))
if network.can_edit(message["thread_id"], message["post_id"]): if network.can_edit(message["thread_id"], message["post_id"]) \
and not self.window_split:
if message["post_id"] == 0: if message["post_id"] == 0:
msg = "Thread" msg = "Thread"
else: msg = "Post" else: msg = "Post"
@ -499,6 +502,9 @@ class App(object):
buttons.insert(0, urwid.Button("Delete %s" % msg, self.deletion_dialog, message)) buttons.insert(0, urwid.Button("Delete %s" % msg, self.deletion_dialog, message))
buttons.insert(0, urwid.Button("Edit Post", self.edit_post, message)) buttons.insert(0, urwid.Button("Edit Post", self.edit_post, message))
if not buttons:
return
widget = OptionsMenu( widget = OptionsMenu(
urwid.ListBox(urwid.SimpleFocusListWalker(buttons)), urwid.ListBox(urwid.SimpleFocusListWalker(buttons)),
title=str(">>%d (%s)" % (message["post_id"], author["user_name"])), title=str(">>%d (%s)" % (message["post_id"], author["user_name"])),