Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lyse
tt
Commits
cc2860c4
Commit
cc2860c4
authored
Jan 01, 2021
by
Lysander Trischler
Browse files
Hide read conversations
parent
aba7cf77
Changes
1
Hide whitespace changes
Inline
Side-by-side
twtxtmanager.py
View file @
cc2860c4
...
...
@@ -21,6 +21,9 @@ 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
=
[]
...
...
@@ -77,7 +80,7 @@ class TwtxtManager:
# TODO Add cyclic dependency check!!
# list of all top level tweets
self
.
conversation_tree
=
replies_by_subject
.
pop
(
None
,
[])
conversation_tree
=
replies_by_subject
.
pop
(
None
,
[])
# build conversation trees
for
twt
in
all_tweets
:
...
...
@@ -107,11 +110,24 @@ class TwtxtManager:
entry
=
self
.
_cache2
.
get
(
hash
)
twt
.
read
=
entry
and
entry
.
get
(
"read"
,
False
)
twt
.
missing
=
True
self
.
conversation_tree
.
append
(
twt
)
conversation_tree
.
append
(
twt
)
self
.
missing_conversation_root_count
+=
1
self
.
conversation_tree
.
sort
()
conversation_tree
.
sort
()
self
.
twts_count
=
len
(
all_tweets
)
if
self
.
show_read_conversations
:
self
.
conversation_tree
=
conversation_tree
else
:
self
.
conversation_tree
=
[]
for
twt
in
conversation_tree
:
if
self
.
show_unread_missing_conversation_roots
:
consider_twt_read
=
twt
.
read
else
:
consider_twt_read
=
(
hasattr
(
twt
,
"missing"
)
and
twt
.
missing
)
or
twt
.
read
if
not
consider_twt_read
or
self
.
_has_unread_replies
(
twt
):
self
.
conversation_tree
.
append
(
twt
)
def
toggle_read
(
self
,
twt
):
"""
...
...
@@ -155,3 +171,16 @@ class TwtxtManager:
return
False
def
_has_unread_replies
(
self
,
twt
):
"""
Determine whether there are any unread replies in the given
conversation without taking the read status of the given twt itself
into account.
"""
for
reply
in
twt
.
replies
:
if
not
reply
.
read
or
self
.
_has_unread_replies
(
reply
):
return
True
return
False
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment