chiark / gitweb /
Option to view a post by its numeric id.
authorSimon Tatham <anakin@pobox.com>
Sun, 17 Dec 2023 11:39:12 +0000 (11:39 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 17 Dec 2023 11:39:12 +0000 (11:39 +0000)
cursesclient.py

index 4b76ee3da4583ed8173d3f5b4b81d95e475914a9..b9703129cd4c386291e34b6c50d4f6646c84845d 100644 (file)
@@ -352,6 +352,10 @@ class MainMenu(Menu):
             '#', text.ColouredString("Timeline for a #hashtag",
                                      "               K       ")))
         self.items.append(text.BlankLine())
+        self.items.append(text.MenuKeypressLine(
+            'I', text.ColouredString("View a post by its ID",
+                                     "                   K ")))
+        self.items.append(text.BlankLine())
         self.items.append(text.MenuKeypressLine(
             'C', text.ColouredString("Compose a post",
                                      "K             ")))
@@ -383,6 +387,10 @@ class MainMenu(Menu):
             self.push_to(BottomLinePrompt(
                 self.cc, self.got_hashtag_to_view,
                 "View feed for hashtag: "))
+        elif ch in {'i', 'I'}:
+            self.push_to(BottomLinePrompt(
+                self.cc, self.got_post_id_to_view,
+                "View post with id: "))
         else:
             return super().handle_key(ch)
 
@@ -396,6 +404,16 @@ class MainMenu(Menu):
             f"Posts mentioning hashtag #{tag}", 'H')
         self.push_to(StatusFile(self.cc, feed, title))
 
+    def got_post_id_to_view(self, post_id):
+        post_id = post_id.strip()
+        if post_id == "":
+            return
+
+        try:
+            self.push_to(StatusInfoFile(self.cc, post_id))
+        except client.HTTPError:
+            curses.beep()
+
 class EscMenu(Menu):
     def __init__(self, cc):
         super().__init__(cc)