diff --git a/toot/ui/app.py b/toot/ui/app.py index 1f7ca55..9658e72 100644 --- a/toot/ui/app.py +++ b/toot/ui/app.py @@ -134,6 +134,9 @@ class StatusListWindow: self.pad.addstr(offset + 1, 1, " " + date.ljust(12), color) self.pad.addstr(offset + 2, 1, " " + time.ljust(12), color) + if status['favourited']: + self.pad.addstr(offset + 2, width - 3, '⭐', Color.YELLOW) + if draw_divider: draw_horizontal_divider(self.pad, offset + 3) @@ -294,6 +297,7 @@ class HelpModal(Modal): " k or ↑ - move up", " v - view current toot in browser", " b - toggle boost status", + " f - toggle favourite status", " q - quit application", " s - show sensitive content" "", @@ -371,6 +375,9 @@ class TimelineApp: elif key.lower() == 'b': self.toggle_reblog() + elif key.lower() == 'f': + self.toggle_favourite() + elif key == 'KEY_RESIZE': self.setup_windows() self.full_redraw() @@ -403,6 +410,27 @@ class TimelineApp: self.right.draw(status) + def toggle_favourite(self): + """Favourite or unfavourite selected status.""" + status = self.get_selected_status() + assert status + app, user = self.app, self.user + if not app or not user: + self.footer.draw_message("You must be logged in to favourite", Color.RED) + return + status_id = status['id'] + if status['favourited']: + self.footer.draw_message("Undoing favourite status...", Color.YELLOW) + api.unfavourite(app, user, status_id) + self.footer.draw_message("✓ Status unfavourited", Color.GREEN) + else: + self.footer.draw_message("Favourite status...", Color.YELLOW) + api.favourite(app, user, status_id) + self.footer.draw_message("✓ Status favourited", Color.GREEN) + status['favourited'] = not status['favourited'] + + self.right.draw(status) + def select_previous(self): """Move to the previous status in the timeline.""" self.footer.clear_message() diff --git a/toot/ui/parsers.py b/toot/ui/parsers.py index e9d7a45..7db4595 100644 --- a/toot/ui/parsers.py +++ b/toot/ui/parsers.py @@ -15,6 +15,7 @@ def parse_status(status): 'boosted_by': boosted_by, 'created_at': created_at, 'content': content, + 'favourited': status.get('favourited'), 'id': status['id'], 'media_attachments': _status['media_attachments'], 'url': _status['url'],