Fall back to "username" when "display_name" is unset

We add a "username" field to Author entity, this is then used when
displaying the "reblogged by" information when respective account has no
display name.
This commit is contained in:
Denis Laxalde 2019-10-01 09:27:27 +02:00 committed by Ivan Habunek
parent fdbed57f23
commit 690a91ce04
2 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@ from collections import namedtuple
from .utils import parse_datetime
Author = namedtuple("Author", ["account", "display_name"])
Author = namedtuple("Author", ["account", "display_name", "username"])
class Status:
@ -73,7 +73,7 @@ class Status:
def _get_author(self):
acct = self.data['account']['acct']
acct = acct if "@" in acct else "{}@{}".format(acct, self.default_instance)
return Author(acct, self.data['account']['display_name'])
return Author(acct, self.data['account']['display_name'], self.data['account']['username'])
def _get_account(self):
acct = self.data['account']['acct']

View File

@ -220,7 +220,7 @@ class StatusDetails(urwid.Pile):
def content_generator(self, status, reblogged_by):
if reblogged_by:
text = "{} boosted".format(reblogged_by.display_name)
text = "{} boosted".format(reblogged_by.display_name or reblogged_by.username)
yield ("pack", urwid.Text(("gray", text)))
yield ("pack", urwid.AttrMap(urwid.Divider("-"), "gray"))