Implement actions for Account
Actions: un/follow, un/mute, un/block are invoked synchronously and the Account overlay window is updated to reflect the changes.
This commit is contained in:
parent
876ad1f53d
commit
85df15f533
2 changed files with 12 additions and 9 deletions
|
@ -523,7 +523,7 @@ class TUI(urwid.Frame):
|
||||||
account = api.whois(self.app, self.user, account_id)
|
account = api.whois(self.app, self.user, account_id)
|
||||||
relationship = api.get_relationship(self.app, self.user, account_id)
|
relationship = api.get_relationship(self.app, self.user, account_id)
|
||||||
self.open_overlay(
|
self.open_overlay(
|
||||||
widget=Account(account, relationship),
|
widget=Account(self.app, self.user, account, relationship),
|
||||||
title="Account",
|
title="Account",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ from toot import __version__
|
||||||
from toot.utils import format_content
|
from toot.utils import format_content
|
||||||
from .utils import highlight_hashtags, highlight_keys
|
from .utils import highlight_hashtags, highlight_keys
|
||||||
from .widgets import Button, EditBox, SelectableText
|
from .widgets import Button, EditBox, SelectableText
|
||||||
|
from toot import api
|
||||||
|
|
||||||
|
|
||||||
class StatusSource(urwid.Padding):
|
class StatusSource(urwid.Padding):
|
||||||
|
@ -205,10 +206,12 @@ class Help(urwid.Padding):
|
||||||
|
|
||||||
class Account(urwid.ListBox):
|
class Account(urwid.ListBox):
|
||||||
"""Shows account data and provides various actions"""
|
"""Shows account data and provides various actions"""
|
||||||
def __init__(self, account, relationship):
|
def __init__(self, app, user, account, relationship):
|
||||||
self.last_action = None
|
self.app = app
|
||||||
|
self.user = user
|
||||||
self.account = account
|
self.account = account
|
||||||
self.relationship = relationship
|
self.relationship = relationship
|
||||||
|
self.last_action = None
|
||||||
self.setup_listbox()
|
self.setup_listbox()
|
||||||
|
|
||||||
def setup_listbox(self):
|
def setup_listbox(self):
|
||||||
|
@ -284,17 +287,17 @@ def take_action(button: Button, self: Account):
|
||||||
action = button.get_label()
|
action = button.get_label()
|
||||||
|
|
||||||
if action == "Confirm Follow":
|
if action == "Confirm Follow":
|
||||||
pass
|
self.relationship = api.follow(self.app, self.user, self.account["id"])
|
||||||
elif action == "Confirm Unfollow":
|
elif action == "Confirm Unfollow":
|
||||||
pass
|
self.relationship = api.unfollow(self.app, self.user, self.account["id"])
|
||||||
elif action == "Confirm Mute":
|
elif action == "Confirm Mute":
|
||||||
pass
|
self.relationship = api.mute(self.app, self.user, self.account["id"])
|
||||||
elif action == "Confirm Unmute":
|
elif action == "Confirm Unmute":
|
||||||
pass
|
self.relationship = api.unmute(self.app, self.user, self.account["id"])
|
||||||
elif action == "Confirm Block":
|
elif action == "Confirm Block":
|
||||||
pass
|
self.relationship = api.block(self.app, self.user, self.account["id"])
|
||||||
elif action == "Confirm Unblock":
|
elif action == "Confirm Unblock":
|
||||||
pass
|
self.relationship = api.unblock(self.app, self.user, self.account["id"])
|
||||||
|
|
||||||
self.last_action = None
|
self.last_action = None
|
||||||
self.setup_listbox()
|
self.setup_listbox()
|
||||||
|
|
Loading…
Reference in a new issue