Skip to content

Commit

Permalink
Improve formatting, remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Jan 2, 2023
1 parent 88c444c commit ff1374a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
11 changes: 3 additions & 8 deletions toot/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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
Expand Down Expand Up @@ -338,10 +339,9 @@ def _done(instance):

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 []

Expand All @@ -350,13 +350,8 @@ def _done_tag_list(tags):
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."""
Expand Down
9 changes: 5 additions & 4 deletions toot/tui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ def _gen():
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


Expand Down

0 comments on commit ff1374a

Please sign in to comment.