From 5a867f23808703fad8b68f8598a20e8efec6c5ac Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Mon, 7 Jan 2019 10:13:29 +0100 Subject: [PATCH] Show number of replies/reblogs/favourites in status footer of curses ui When parsing "replies_count" from status data, we allow the field to be absent as it got added in version 2.5.0 (in constrast with other ones, added in 0.1.0) as there might be servers with that version around. --- toot/ui/app.py | 6 ++++++ toot/ui/parsers.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/toot/ui/app.py b/toot/ui/app.py index 2521428..4520410 100644 --- a/toot/ui/app.py +++ b/toot/ui/app.py @@ -221,6 +221,12 @@ class StatusDetailWindow: if status['reblogged']: yield "↷ Boosted", Color.CYAN + yield ( + "{replies_count} replies, " + "{reblogs_count} reblogs, " + "{favourites_count} favourites" + ).format(**status), Color.CYAN + def draw(self, status): self.window.erase() self.window.box() diff --git a/toot/ui/parsers.py b/toot/ui/parsers.py index c5bc564..ba2f75b 100644 --- a/toot/ui/parsers.py +++ b/toot/ui/parsers.py @@ -16,11 +16,14 @@ def parse_status(status): 'created_at': created_at, 'content': content, 'favourited': status.get('favourited'), + 'favourites_count': _status['favourites_count'], 'id': status['id'], 'in_reply_to_id': _status.get('in_reply_to_id'), 'media_attachments': _status['media_attachments'], 'url': _status['url'], 'reblogged': status.get('reblogged'), + 'reblogs_count': _status['reblogs_count'], + 'replies_count': _status.get('replies_count', 0), 'spoiler_text': spoiler_text, 'sensitive': _status['sensitive'], 'show_sensitive': False,