From 690a91ce04c2d44cbd646f63c79ced85a9685cf8 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Tue, 1 Oct 2019 09:27:27 +0200 Subject: [PATCH] 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. --- toot/tui/entities.py | 4 ++-- toot/tui/timeline.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/toot/tui/entities.py b/toot/tui/entities.py index 207a7b3..3cf2122 100644 --- a/toot/tui/entities.py +++ b/toot/tui/entities.py @@ -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'] diff --git a/toot/tui/timeline.py b/toot/tui/timeline.py index 2ad1051..a414c1d 100644 --- a/toot/tui/timeline.py +++ b/toot/tui/timeline.py @@ -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"))