mirror of
https://github.com/ihabunek/toot.git
synced 2024-06-30 06:35:24 +00:00
Add favourite/unfavourite actions to curses ui
This commit is contained in:
parent
e676f34683
commit
41d96249ba
|
@ -294,6 +294,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 +372,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 +407,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()
|
||||
|
|
|
@ -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'],
|
||||
|
|
Loading…
Reference in New Issue
Block a user