mirror of
https://github.com/ihabunek/toot.git
synced 2025-01-03 14:56:37 -05:00
Add reblog/unreblog actions to curses ui
This is implemented using "b" key to toggle reblog/unreblog based on the value of "reblogged" field in status data.
This commit is contained in:
parent
066589bf53
commit
c6bc4a695f
@ -2,7 +2,7 @@
|
||||
|
||||
import webbrowser
|
||||
|
||||
from toot import __version__
|
||||
from toot import __version__, api
|
||||
|
||||
from toot.exceptions import ConsoleError
|
||||
from toot.ui.parsers import parse_status
|
||||
@ -293,6 +293,7 @@ class HelpModal(Modal):
|
||||
" j or ↓ - move down",
|
||||
" k or ↑ - move up",
|
||||
" v - view current toot in browser",
|
||||
" b - toggle boost/reblog status",
|
||||
" q - quit application",
|
||||
" s - show sensitive content"
|
||||
"",
|
||||
@ -367,6 +368,9 @@ class TimelineApp:
|
||||
elif key.lower() == 's':
|
||||
self.show_sensitive()
|
||||
|
||||
elif key.lower() == 'b':
|
||||
self.toggle_reblog()
|
||||
|
||||
elif key == 'KEY_RESIZE':
|
||||
self.setup_windows()
|
||||
self.full_redraw()
|
||||
@ -377,6 +381,23 @@ class TimelineApp:
|
||||
status['show_sensitive'] = True
|
||||
self.right.draw(status)
|
||||
|
||||
def toggle_reblog(self):
|
||||
"""Reblog or unreblog 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 reblog", Color.RED)
|
||||
return
|
||||
status_id = status['id']
|
||||
if status['reblogged']:
|
||||
action = 'unreblogged'
|
||||
api.unreblog(app, user, status_id)
|
||||
else:
|
||||
action = 'reblogged'
|
||||
api.reblog(app, user, status_id)
|
||||
self.footer.draw_message("Status {}".format(action), Color.GREEN)
|
||||
|
||||
def select_previous(self):
|
||||
"""Move to the previous status in the timeline."""
|
||||
self.footer.clear_message()
|
||||
|
Loading…
Reference in New Issue
Block a user