From 9d0d1b2dd7289b72900a58c4c8182e831e19ffb7 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Fri, 6 Sep 2019 16:01:04 +0200 Subject: [PATCH] Make "view" action work for reblogged statuses When the status is a reblog, the URL of the original toot should be used as the one of reblog is null. We add a "url" attribute to Status class storing computed URL. --- toot/tui/entities.py | 3 +++ toot/tui/timeline.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/toot/tui/entities.py b/toot/tui/entities.py index 324a774..050d005 100644 --- a/toot/tui/entities.py +++ b/toot/tui/entities.py @@ -31,6 +31,9 @@ class Status: self.reblogged = data.get("reblogged", False) self.in_reply_to = data.get("in_reply_to_id") + reblog = data.get("reblog") + self.url = reblog.get("url") if reblog else data.get("url") + def get_author(self): # Show the author, not the persopn who reblogged data = self.data["reblog"] or self.data diff --git a/toot/tui/timeline.py b/toot/tui/timeline.py index 1574536..5b2f536 100644 --- a/toot/tui/timeline.py +++ b/toot/tui/timeline.py @@ -149,8 +149,8 @@ class Timeline(urwid.Columns): return if key in ("v", "V"): - if status.data["url"]: - webbrowser.open(status.data["url"]) + if status.url: + webbrowser.open(status.url) return return super().keypress(size, key)