Commit 8ebfed3b authored by Lysander Trischler's avatar Lysander Trischler

Extract internal show settings into config file

parent 5909def9
......@@ -313,6 +313,32 @@ actual purpose. If you happen to run a ``tt`` version prior to 2021-09-19 and
don't want to move it after a ``tt`` upgrade, you need to explicitly configure
the old path in your config.
Flag indicating whether to show or hide read conversation trees. When enabled,
all conversations are always shown. When disabled, conversation trees are
hidden if all twts in the conversation tree are read. Defaults to ``False``.
See also ``show_unread_missing_conversation_roots`` for more control.
Conversations may be started by feeds you don't follow (yet) or a twt in a feed
you follow, but haven't fetched that twt yet due to a pending update. Such twts
are missing conversation roots. It's often a good practice to not mark those
twts as read, since you haven't actually read them and it would be hard to find
them later on, when they become available.
So this flag controls whether to show or hide conversation trees which are
started by such an unread missing root twt, but all other twts in this
conversation tree are read. If enabled, affected conversation trees are shown,
otherwise they're hidden. It defaults to ``False``.
This setting is related to ``show_read_conversations`` but only affects missing
unread conversation roots.
......@@ -26,9 +26,6 @@ class TwtxtManager:
self.unread_twts_count = 0
self.read_twts_count = 0
self.show_read_conversations = False
self.show_unread_missing_conversation_roots = False
def load_twts(self):
all_tweets = []
......@@ -116,12 +113,12 @@ class TwtxtManager:
self.twts_count = len(all_tweets)
if self.show_read_conversations:
if self.config.show_read_conversations:
self.conversation_tree = conversation_tree
self.conversation_tree = []
for twt in conversation_tree:
if self.show_unread_missing_conversation_roots:
if self.config.show_unread_missing_conversation_roots:
consider_twt_read =
consider_twt_read = (hasattr(twt, "missing") and twt.missing) or
......@@ -272,6 +269,14 @@ class Config:
return path
return os.path.join(base_path, path)
def show_read_conversations(self):
return self._cfg.getboolean("twtxt", "show_read_conversations", fallback=False)
def show_unread_missing_conversation_roots(self):
return self._cfg.getboolean("twtxt", "show_unread_missing_conversation_roots", fallback=False)
def colors(self, name):
return self._cfg.get("colors", name, fallback=None)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment