Add relationship support to Account overlay
Display relationship details such as followed_by, blocked_by, and add buttons to un/follow, un/mute, un/block. Buttons are nonfunctional for now
This commit is contained in:
parent
95473fcd6e
commit
a1490461bd
3 changed files with 31 additions and 4 deletions
12
toot/debugger.py
Normal file
12
toot/debugger.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from os import getenv
|
||||
|
||||
def initialize_debugger():
|
||||
import multiprocessing
|
||||
|
||||
if multiprocessing.current_process().pid > 1:
|
||||
import debugpy
|
||||
|
||||
debugpy.listen(("0.0.0.0", 9000))
|
||||
print("VSCode Debugger is ready to be attached on port 9000, press F5", flush=True)
|
||||
debugpy.wait_for_client()
|
||||
print("VSCode Debugger is now attached", flush=True)
|
|
@ -521,8 +521,9 @@ class TUI(urwid.Frame):
|
|||
|
||||
def show_account(self, account_id):
|
||||
account = api.whois(self.app, self.user, account_id)
|
||||
relationship = api.get_relationship(self.app, self.user, account_id)
|
||||
self.open_overlay(
|
||||
widget=Account(account),
|
||||
widget=Account(account, relationship),
|
||||
title="Account",
|
||||
)
|
||||
|
||||
|
|
|
@ -205,12 +205,20 @@ class Help(urwid.Padding):
|
|||
|
||||
class Account(urwid.ListBox):
|
||||
"""Shows account data and provides various actions"""
|
||||
def __init__(self, account):
|
||||
actions = list(self.generate_contents(account))
|
||||
def __init__(self, account, relationship):
|
||||
actions = list(self.generate_contents(account, relationship))
|
||||
walker = urwid.SimpleListWalker(actions)
|
||||
super().__init__(walker)
|
||||
|
||||
def generate_contents(self, account):
|
||||
def generate_contents(self, account, relationship):
|
||||
if relationship['requested']:
|
||||
yield urwid.Text(("light grey", "< Follow request is pending >"))
|
||||
else:
|
||||
yield Button("Unfollow" if relationship['following'] else "Follow")
|
||||
yield Button("Unmute" if relationship['muting'] else "Mute")
|
||||
yield Button("Unblock" if relationship['blocking'] else "Block")
|
||||
yield urwid.Divider("─")
|
||||
yield urwid.Divider()
|
||||
yield urwid.Text([('green', f"@{account['acct']}"), f" {account['display_name']}"])
|
||||
|
||||
if account["note"]:
|
||||
|
@ -232,6 +240,12 @@ class Account(urwid.ListBox):
|
|||
if "suspended" in account and account["suspended"]:
|
||||
yield urwid.Text([("warning", "Suspended \N{cross mark}")])
|
||||
yield urwid.Divider()
|
||||
if relationship["followed_by"]:
|
||||
yield urwid.Text(("green", "Follows you \N{busts in silhouette}"))
|
||||
yield urwid.Divider()
|
||||
if relationship["blocked_by"]:
|
||||
yield urwid.Text(("warning", "Blocks you \N{no entry}"))
|
||||
yield urwid.Divider()
|
||||
|
||||
yield urwid.Text(["Followers: ", ("yellow", f"{account['followers_count']}")])
|
||||
yield urwid.Text(["Following: ", ("yellow", f"{account['following_count']}")])
|
||||
|
|
Loading…
Reference in a new issue