From: Simon Tatham Date: Sun, 17 Dec 2023 07:49:15 +0000 (+0000) Subject: Graduations of mode to view a user's posts. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=87976b17aa66ae82a88fa6b650ea3c2e2079d95b;p=mastodonochrome.git Graduations of mode to view a user's posts. 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...) --- diff --git a/client.py b/client.py index 365a34a..7a0b792 100644 --- 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): diff --git a/cursesclient.py b/cursesclient.py index eae42f1..d820a70 100644 --- a/cursesclient.py +++ b/cursesclient.py @@ -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)