Added support for loading more items in conversation buffers
This commit is contained in:
@@ -66,6 +66,9 @@ class vkSession(object):
|
||||
self.db[name] = {}
|
||||
self.db[name]["items"] = []
|
||||
first_addition = True
|
||||
# Handles chat messages case, as the buffer is inverted
|
||||
if name.endswith("_messages") and show_nextpage == True:
|
||||
show_nextpage = False
|
||||
for i in data:
|
||||
if "type" in i and not isinstance(i["type"], int) and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
|
||||
log.debug("Skipping unsupported item... %r" % (i,))
|
||||
@@ -192,6 +195,10 @@ class vkSession(object):
|
||||
if data != None:
|
||||
if "count" not in kwargs:
|
||||
kwargs["count"] = 100
|
||||
# Let's handle a little exception when dealing with conversation buffers.
|
||||
# the first results of the query should be reversed before being sent to order_buffer.
|
||||
if type(data) == dict and "items" in data and endpoint == "getHistory" and kwargs["offset"] == 0:
|
||||
data["items"].reverse()
|
||||
if type(data) == dict:
|
||||
num = self.order_buffer(name, data["items"], show_nextpage)
|
||||
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
|
||||
|
Reference in New Issue
Block a user