It is possible to load previous items in the home buffer properly, and the feature works too in wall buffers and timelines

This commit is contained in:
Manuel Cortez 2019-02-11 04:53:32 -06:00
parent fbada0c4be
commit 4b6d5a86b2
3 changed files with 14 additions and 0 deletions

View File

@ -25,6 +25,9 @@
* It is possible to enable or disable proxy from the preferences dialog. The application must be restarted for this change to take effect. * It is possible to enable or disable proxy from the preferences dialog. The application must be restarted for this change to take effect.
* Fixed an error that was making Socializer unable to display the changelog properly, when opened from the help menu. ([#21](https://code.manuelcortez.net/manuelcortez/socializer/issues/21)) * Fixed an error that was making Socializer unable to display the changelog properly, when opened from the help menu. ([#21](https://code.manuelcortez.net/manuelcortez/socializer/issues/21))
* When receiving chat messages and in some other situations, socializer will display all characters properly. Before, usernames were rendered using the internal code VK uses for them, and some unicode characters were displaying their HTML representation. * When receiving chat messages and in some other situations, socializer will display all characters properly. Before, usernames were rendered using the internal code VK uses for them, and some unicode characters were displaying their HTML representation.
* It is possible to retrieve previous items for the home buffer and walls (current user's wall and any other timeline):
* For the home buffer, only a limited amount of items (around 700) can be loaded, supposedly due to VK API limits.
* For walls, all posts should be possible to be loaded, however, testing with walls containing more than 2000 posts are not performed yet.
* Added improvements to groups: * Added improvements to groups:
* It is possible to load topics, audios and videos for a group. In order to do so, you need to go to the group buffer and press the menu key, or right mouse click, in the tree item representing the group. New buffers will be created inside the current group's buffer. * It is possible to load topics, audios and videos for a group. In order to do so, you need to go to the group buffer and press the menu key, or right mouse click, in the tree item representing the group. New buffers will be created inside the current group's buffer.
* You can create or delete all buffers for groups by pressing the menu key or right mouse click in the "communities" buffer. * You can create or delete all buffers for groups by pressing the menu key or right mouse click in the "communities" buffer.

View File

@ -410,6 +410,9 @@ class feedBuffer(baseBuffer):
[self.insert(i, True) for i in v] [self.insert(i, True) for i in v]
else: else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]] [self.insert(i) for i in self.session.db[self.name]["items"][:num]]
else:
if num > 0:
[self.insert(i, False) for i in self.session.db[self.name]["items"][-num:]]
return retrieved return retrieved
def remove_buffer(self, mandatory=False): def remove_buffer(self, mandatory=False):

View File

@ -163,11 +163,18 @@ class vkSession(object):
p = getattr(c, p) p = getattr(c, p)
except AttributeError: except AttributeError:
p = c p = c
if name in self.db and "offset" in self.db[name]:
kwargs.update(offset=self.db[name]["offset"])
else:
kwargs.update(offset=0)
log.debug("Calling endpoint %s with params %r" % (p, kwargs,)) log.debug("Calling endpoint %s with params %r" % (p, kwargs,))
data = getattr(p, endpoint)(*args, **kwargs) data = getattr(p, endpoint)(*args, **kwargs)
if data != None: if data != None:
if "count" not in kwargs:
kwargs["count"] = 100
if type(data) == dict: if type(data) == dict:
num = self.order_buffer(name, data["items"], show_nextpage) num = self.order_buffer(name, data["items"], show_nextpage)
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
if len(data["items"]) > 0 and "first_name" in data["items"][0]: if len(data["items"]) > 0 and "first_name" in data["items"][0]:
data2 = {"profiles": [], "groups": []} data2 = {"profiles": [], "groups": []}
for i in data["items"]: for i in data["items"]:
@ -177,6 +184,7 @@ class vkSession(object):
self.process_usernames(data) self.process_usernames(data)
else: else:
num = self.order_buffer(name, data, show_nextpage) num = self.order_buffer(name, data, show_nextpage)
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
return num return num
def get_messages(self, name="", *args, **kwargs): def get_messages(self, name="", *args, **kwargs):