1
0
mirror of https://github.com/ihabunek/toot.git synced 2024-11-03 04:17:21 -05:00

Improve formatting, remove logging

This commit is contained in:
Ivan Habunek 2023-01-02 14:24:39 +01:00
parent 88c444c411
commit ff1374a95c
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
2 changed files with 8 additions and 12 deletions

View File

@ -5,6 +5,7 @@ from concurrent.futures import ThreadPoolExecutor
from toot import api, config, __version__
from toot.console import get_default_visibility
from toot.exceptions import ApiError
from .compose import StatusComposer
from .constants import PALETTE
@ -338,10 +339,9 @@ class TUI(urwid.Frame):
def async_load_followed_tags(self):
def _load_tag_list():
logger.info("Loading tags")
try:
return api.followed_tags(self.app, self.user)
except:
except ApiError:
# not supported by all Mastodon servers so fail silently if necessary
return []
@ -350,13 +350,8 @@ class TUI(urwid.Frame):
self.followed_tags = [t["name"] for t in tags]
else:
self.followed_tags = []
logger.info("Loaded tags. Followed tags = {}".format(self.followed_tags))
self.run_in_thread(
_load_tag_list, done_callback=_done_tag_list
)
self.run_in_thread(_load_tag_list, done_callback=_done_tag_list)
def refresh_footer(self, timeline):
"""Show status details in footer."""

View File

@ -51,17 +51,18 @@ def highlight_keys(text, high_attr, low_attr=""):
return list(_gen())
def highlight_hashtags(line, followed_tags, attr="hashtag",\
followed_attr="followed_hashtag"):
def highlight_hashtags(line, followed_tags, attr="hashtag", followed_attr="followed_hashtag"):
hline = []
for p in re.split(HASHTAG_PATTERN, line):
if p.startswith("#"):
if p[1:].lower() in (t.lower() for t in followed_tags):
hline.append((followed_attr,p))
hline.append((followed_attr, p))
else:
hline.append((attr,p))
hline.append((attr, p))
else:
hline.append(p)
return hline