From d399eec6f5b8f9ef46cdecdac03f717e40d0dedc Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Fri, 10 Feb 2023 21:48:42 -0500 Subject: [PATCH] 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 --- toot/tui/timeline.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/toot/tui/timeline.py b/toot/tui/timeline.py index 9059f5e..cfa88b8 100644 --- a/toot/tui/timeline.py +++ b/toot/tui/timeline.py @@ -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):