Mastodon: Added reverse timeline ordering to buffers

This commit is contained in:
Manuel Cortez 2022-12-10 18:52:07 -06:00
parent ffbb67765d
commit a3bc684721
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
4 changed files with 8 additions and 12 deletions

View File

@ -93,6 +93,9 @@ class BaseBuffer(base.Buffer):
min_id = None min_id = None
# toDo: Implement reverse timelines properly here. # toDo: Implement reverse timelines properly here.
if (self.name != "favorites" and self.name != "bookmarks") and self.name in self.session.db and len(self.session.db[self.name]) > 0: if (self.name != "favorites" and self.name != "bookmarks") and self.name in self.session.db and len(self.session.db[self.name]) > 0:
if self.session.settings["general"]["reverse_timelines"]:
min_id = self.session.db[self.name][0].id
else:
min_id = self.session.db[self.name][-1].id min_id = self.session.db[self.name][-1].id
try: try:
results = getattr(self.session.api, self.function)(min_id=min_id, limit=count, *self.args, **self.kwargs) results = getattr(self.session.api, self.function)(min_id=min_id, limit=count, *self.args, **self.kwargs)
@ -152,7 +155,7 @@ class BaseBuffer(base.Buffer):
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(True, *post) self.buffer.list.insert_item(True, *post)
else: else:
for i in items: for i in elements:
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *post) self.buffer.list.insert_item(False, *post)
self.buffer.list.select_item(selection) self.buffer.list.select_item(selection)

View File

@ -46,9 +46,6 @@ class ConversationListBuffer(BaseBuffer):
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
count = self.session.settings["general"]["max_posts_per_call"] count = self.session.settings["general"]["max_posts_per_call"]
min_id = None min_id = None
# toDo: Implement reverse timelines properly here.
# if (self.name != "favorites" and self.name != "bookmarks") and self.name in self.session.db and len(self.session.db[self.name]) > 0:
# min_id = self.session.db[self.name][-1].id
try: try:
results = getattr(self.session.api, self.function)(min_id=min_id, limit=count, *self.args, **self.kwargs) results = getattr(self.session.api, self.function)(min_id=min_id, limit=count, *self.args, **self.kwargs)
results.reverse() results.reverse()
@ -94,7 +91,7 @@ class ConversationListBuffer(BaseBuffer):
conversation = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) conversation = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(True, *conversation) self.buffer.list.insert_item(True, *conversation)
else: else:
for i in items: for i in elements:
conversation = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) conversation = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *conversation) self.buffer.list.insert_item(False, *conversation)
self.buffer.list.select_item(selection) self.buffer.list.select_item(selection)

View File

@ -16,9 +16,6 @@ class MentionsBuffer(BaseBuffer):
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
count = self.session.settings["general"]["max_posts_per_call"] count = self.session.settings["general"]["max_posts_per_call"]
min_id = None min_id = None
# toDo: Implement reverse timelines properly here.
# if self.name != "favorites" and self.name in self.session.db and len(self.session.db[self.name]) > 0:
# min_id = self.session.db[self.name][-1].id
try: try:
items = getattr(self.session.api, self.function)(min_id=min_id, limit=count, exclude_types=["follow", "favourite", "reblog", "poll", "follow_request"], *self.args, **self.kwargs) items = getattr(self.session.api, self.function)(min_id=min_id, limit=count, exclude_types=["follow", "favourite", "reblog", "poll", "follow_request"], *self.args, **self.kwargs)
items.reverse() items.reverse()
@ -64,7 +61,7 @@ class MentionsBuffer(BaseBuffer):
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(True, *post) self.buffer.list.insert_item(True, *post)
else: else:
for i in items: for i in elements:
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *post) self.buffer.list.insert_item(False, *post)
self.buffer.list.select_item(selection) self.buffer.list.select_item(selection)

View File

@ -75,7 +75,6 @@ class UserBuffer(BaseBuffer):
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type)) log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
count = self.session.settings["general"]["max_posts_per_call"] count = self.session.settings["general"]["max_posts_per_call"]
# toDo: Implement reverse timelines properly here.
try: try:
results = getattr(self.session.api, self.function)(limit=count, *self.args, **self.kwargs) results = getattr(self.session.api, self.function)(limit=count, *self.args, **self.kwargs)
if hasattr(results, "_pagination_next") and self.name not in self.session.db["pagination_info"]: if hasattr(results, "_pagination_next") and self.name not in self.session.db["pagination_info"]:
@ -127,7 +126,7 @@ class UserBuffer(BaseBuffer):
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(True, *post) self.buffer.list.insert_item(True, *post)
else: else:
for i in items: for i in elements:
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *post) self.buffer.list.insert_item(False, *post)
self.buffer.list.select_item(selection) self.buffer.list.select_item(selection)