Skip to content

Commit

Permalink
Fall back to "username" when "display_name" is unset
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Denis Laxalde authored and ihabunek committed Jan 22, 2020
1 parent fdbed57 commit 690a91c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions toot/tui/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .utils import parse_datetime

Author = namedtuple("Author", ["account", "display_name"])
Author = namedtuple("Author", ["account", "display_name", "username"])


class Status:
Expand Down Expand Up @@ -73,7 +73,7 @@ def _get_reblog(self):
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']
Expand Down
2 changes: 1 addition & 1 deletion toot/tui/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def __init__(self, status, in_thread):

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"))

Expand Down

0 comments on commit 690a91c

Please sign in to comment.