From 6047a51c4face5eb37feebff33bf7ef6892f4049 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Wed, 15 Mar 2023 09:43:54 +0100 Subject: [PATCH] Pass the TUI object to Timeline in constructor --- toot/tui/app.py | 4 ++-- toot/tui/timeline.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/toot/tui/app.py b/toot/tui/app.py index 0ce7be2..21315dc 100644 --- a/toot/tui/app.py +++ b/toot/tui/app.py @@ -260,7 +260,7 @@ class TUI(urwid.Frame): self.loop.set_alarm_in(5, lambda *args: self.footer.clear_message()) config.save_config(self.config) - timeline = Timeline(name, statuses, self.can_translate, self.followed_tags, self.followed_accounts) + timeline = Timeline(self, name, statuses, self.can_translate, self.followed_tags, self.followed_accounts) self.connect_default_timeline_signals(timeline) urwid.connect_signal(timeline, "next", _next) @@ -289,7 +289,7 @@ class TUI(urwid.Frame): statuses = ancestors + [status] + descendants focus = len(ancestors) - timeline = Timeline("thread", statuses, self.can_translate, + timeline = Timeline(self, "thread", statuses, self.can_translate, self.followed_tags, self.followed_accounts, focus, is_thread=True) self.connect_default_timeline_signals(timeline) diff --git a/toot/tui/timeline.py b/toot/tui/timeline.py index 42299e1..e70a8a2 100644 --- a/toot/tui/timeline.py +++ b/toot/tui/timeline.py @@ -9,9 +9,10 @@ from .entities import Status from .scroll import Scrollable, ScrollBar from .utils import highlight_hashtags, parse_datetime, highlight_keys from .widgets import SelectableText, SelectableColumns +from toot.tui import app +from toot.tui.utils import time_ago from toot.utils import format_content from toot.utils.language import language_name -from toot.tui.utils import time_ago logger = logging.getLogger("toot") @@ -45,6 +46,7 @@ class Timeline(urwid.Columns): ] def __init__(self, + tui: "app.TUI", name, statuses, can_translate, @@ -53,6 +55,7 @@ class Timeline(urwid.Columns): focus=0, is_thread=False): + self.tui = tui self.name = name self.is_thread = is_thread self.statuses = statuses