When prepending items to the beginning of the list (which happens when
loading new statuses), limit the size of the list to self.MAX_LENGTH to
prevent it from growing forever.
MAX_LENGTH is currently set to 1024, which should be more than enough
for most users.
This doesn't affect scrolling backward through the timeline: events are
only removed when the timeline is refreshed.
---
tooi/widgets/event_list.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tooi/widgets/event_list.py b/tooi/widgets/event_list.py
index d16eecf..a96763b 100644
--- a/tooi/widgets/event_list.py+++ b/tooi/widgets/event_list.py
@@ -14,6 +14,10 @@ class EventList(ListView):
A ListView that shows a list of events.
"""
+ # When prepending events, if we have more than this many events, start removing events from the+ # end.+ MAX_LENGTH = 1024+ DEFAULT_CSS = """
EventList {
width: 1fr;
@@ -62,6 +66,9 @@ class EventList(ListView):
if self.current is not None:
self.post_message(EventHighlighted(self.current))
+ for item in self.query(EventListItem)[self.MAX_LENGTH:]:+ item.remove()+ def focus_event(self, event_id: str):
for i, item in enumerate(self.query(EventListItem)):
if item.event.id == event_id:
--
2.43.0