1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-23 23:52:40 +01:00

Implement [P]oll command to view/vote on poll

Note that this change also switches some key meanings:
E -> X for View E[x]ception
P -> E for Sav[e] Timeline
to accomodate P for [P]oll
This commit is contained in:
Daniel Schwarz 2023-02-10 21:48:42 -05:00
parent c2faa7e2b6
commit d399eec6f5

View File

@ -31,6 +31,7 @@ class Timeline(urwid.Columns):
"media", # Display media attachments
"menu", # Show a context menu
"next", # Fetch more statuses
"poll", # Vote in a poll
"reblog", # Reblog status
"reply", # Compose a reply to a status
"source", # Show status source
@ -102,6 +103,8 @@ class Timeline(urwid.Columns):
if not status:
return None
poll = status.data.get("poll")
options = [
"[A]ccount" if not status.is_mine else "",
"[B]oost",
@ -112,6 +115,7 @@ class Timeline(urwid.Columns):
"[T]hread" if not self.is_thread else "",
"[L]inks",
"[R]eply",
"[P]oll" if poll and not poll["expired"] else "",
"So[u]rce",
"[Z]oom",
"Tra[n]slate" if self.can_translate else "",
@ -240,7 +244,7 @@ class Timeline(urwid.Columns):
self._emit("clear-screen")
return
if key in ("p", "P"):
if key in ("e", "E"):
self._emit("save", status)
return
@ -248,6 +252,12 @@ class Timeline(urwid.Columns):
self._emit("zoom", self.status_details)
return
if key in ("p", "P"):
poll = status.data.get("poll")
if poll and not poll["expired"]:
self._emit("poll", status)
return
return super().keypress(size, key)
def append_status(self, status):