chiark / gitweb /
Graduations of mode to view a user's posts.
authorSimon Tatham <anakin@pobox.com>
Sun, 17 Dec 2023 07:49:15 +0000 (07:49 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 17 Dec 2023 07:49:15 +0000 (07:49 +0000)
Now we can exclude blogs, and also exclude replies to other threads.

(Interestingly, the 'exclude replies' flag in the API only excludes
replies to _other_ accounts. So it keeps replies to _yourself_. One
effect of this is that if you post a multitoot thread, it all shows up
in this list. Of course the client could filter it too...)

client.py
cursesclient.py

index 365a34a64a247814b262fb212fdd28d439121170..7a0b7920d51622c08db2a08fc13410871384e431 100644 (file)
--- a/client.py
+++ b/client.py
@@ -257,8 +257,12 @@ class MentionsFeed(IncrementalServerFeed):
                          get=lambda item: item['status'])
 
 class UserStatusesFeed(IncrementalServerFeed):
-    def __init__(self, client, account_id):
-        super().__init__(client, f"accounts/{account_id}/statuses", {})
+    def __init__(self, client, account_id, include_boosts=True,
+                 include_replies=True):
+        super().__init__(client, f"accounts/{account_id}/statuses", {
+            'exclude_replies': not include_replies,
+            'exclude_reblogs': not include_boosts,
+        })
 
 class UserListFeed(IncrementalServerFeed):
     def __init__(self, client, url):
index eae42f17554070551f64d65019f9114f5ff2cc28..d820a707b60c5d1f876c7154fb7b3da0fce7daa1 100644 (file)
@@ -743,6 +743,12 @@ class ObjectFile(File):
                 sl.keys.append(('F', 'List Favouriters'))
                 sl.keys.append(('B', 'List Boosters'))
             sl.keys.append(('Q', 'Quit'))
+        elif self.mode == 'list_posts':
+            if isinstance(self, UserInfoFile):
+                sl.keys.append(('A', 'All'))
+                sl.keys.append(('O', 'Original'))
+                sl.keys.append(('T', 'Top-level'))
+            sl.keys.append(('Q', 'Quit'))
         else:
             if self.linepos >= len(self.lines):
                 sl.keys.append(('-', 'Up'))
@@ -979,10 +985,32 @@ class UserInfoFile(ObjectFile):
 
     def handle_key(self, ch):
         if self.mode == 'normal' and ch in {'p', 'P'}:
-            feed = client.UserStatusesFeed(self.cc, self.account_id)
+            self.mode = 'list_posts'
+        elif self.mode == 'list_posts' and ch in {'a', 'A'}:
+            feed = client.UserStatusesFeed(
+                self.cc, self.account_id,
+                include_boosts=True, include_replies=True)
+            name = self.cc.fq(self.account['acct'])
+            title = text.ColouredString(f"All posts from user {name}", 'H')
+            self.chain_to(StatusFile(self.cc, feed, title))
+        elif self.mode == 'list_posts' and ch in {'o', 'O'}:
+            feed = client.UserStatusesFeed(
+                self.cc, self.account_id,
+                include_boosts=False, include_replies=True)
+            name = self.cc.fq(self.account['acct'])
+            title = text.ColouredString(f"Original posts from user {name}", 'H')
+            self.chain_to(StatusFile(self.cc, feed, title))
+        elif self.mode == 'list_posts' and ch in {'t', 'T'}:
+            feed = client.UserStatusesFeed(
+                self.cc, self.account_id,
+                include_boosts=False, include_replies=False)
             name = self.cc.fq(self.account['acct'])
-            title = text.ColouredString(f"Posts from user {name}", 'H')
+            title = text.ColouredString(
+                f"Top-level posts from user {name}", 'H')
             self.chain_to(StatusFile(self.cc, feed, title))
+        elif self.mode == 'list_posts':
+            self.mode = 'normal'
+
         elif self.mode == 'normal' and ch in {'l', 'L'}:
             self.mode = 'list_users'
         elif self.mode == 'list_users' and ch in {'i', 'I'}:
@@ -999,6 +1027,7 @@ class UserInfoFile(ObjectFile):
             self.chain_to(UserListFile(self.cc, feed, title))
         elif self.mode == 'list_users':
             self.mode = 'normal'
+
         else:
             return super().handle_key(ch)