chiark / gitweb /
Allow changing the visibility of posts.
authorSimon Tatham <anakin@pobox.com>
Sat, 9 Dec 2023 17:57:32 +0000 (17:57 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 9 Dec 2023 17:57:32 +0000 (17:57 +0000)
cursesclient.py

index 1768d340323d2df8ce01730bdbbff97889b44017..f6898524b87c7e0b02f337bba6c28b37bcad85bf 100644 (file)
@@ -1043,6 +1043,7 @@ class Composer(Activity, EditorCommon):
 
         self.language = "en" # FIXME: find a better default from somewhere
         self.content_warning = ""
+        self.visibility = "public"
 
     def render(self):
         y = 0
@@ -1170,7 +1171,7 @@ class Composer(Activity, EditorCommon):
     def post(self):
         params = {
             "status": self.text.rstrip("\n"),
-            "visibility": "public",
+            "visibility": self.visibility,
             "language": self.language,
         }
         if self.reply_id is not None:
@@ -1202,6 +1203,13 @@ class PostMenu(Menu):
         self.items.append(text.MenuKeypressLine(
             'A', text.ColouredString("Re-edit post")))
         self.items.append(text.BlankLine())
+        self.items.append(text.MenuKeypressLine(
+            'V', text.ColouredString("Visibility: " +
+                                     self.composer.visibility)))
+        # FIXME: including a help string here would be nice - plus a
+        # warning if you haven't actually mentioned any users and are
+        # selecting 'direct'?
+        self.items.append(text.BlankLine())
         cw = ('none' if self.composer.content_warning == ''
               else f"'{self.composer.content_warning}'")
         self.items.append(text.MenuKeypressLine(
@@ -1232,6 +1240,12 @@ class PostMenu(Menu):
             self.push_to(BottomLinePrompt(
                 self.cc, self.set_content_warning, "Content warning: ",
                 self.composer.content_warning))
+        elif ch in {'v', 'V'}:
+            visibilities = ['public', 'unlisted', 'private', 'direct']
+            nextvis = {visibilities[i-1]: visibilities[i]
+                       for i in range(len(visibilities))}
+            self.composer.visibility = nextvis[self.composer.visibility]
+            self.refresh_items()
         elif ch in {' '}:
             self.composer.post()
             self.cc.composer = None