Chats with more than 200 messages will be displayed properly

This commit is contained in:
Manuel Cortez 2018-11-04 01:39:06 -06:00
parent 6bf29a45db
commit 0936ae6fb6
2 changed files with 3 additions and 1 deletions

View File

@ -358,7 +358,7 @@ class Controller(object):
self.window.change_buffer(pos) self.window.change_buffer(pos)
return b.tab.text.SetFocus() return b.tab.text.SetFocus()
return return
buffer = buffers.chatBuffer(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="compose_message", session=self.session, count=200, user_id=user_id, rev=1) buffer = buffers.chatBuffer(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="compose_message", session=self.session, count=200, user_id=user_id, rev=0)
self.buffers.append(buffer) self.buffers.append(buffer)
# Translators: {0} will be replaced with an user. # Translators: {0} will be replaced with an user.
self.window.insert_buffer(buffer.tab, _(u"Chat with {0}").format(self.session.get_user_name(user_id, "ins")), self.window.search("chats")) self.window.insert_buffer(buffer.tab, _(u"Chat with {0}").format(self.session.get_user_name(user_id, "ins")), self.window.search("chats"))
@ -372,6 +372,7 @@ class Controller(object):
def get_chat(self, obj=None): def get_chat(self, obj=None):
""" Searches or creates a chat buffer with the id of the user that is sending or receiving a message. """ Searches or creates a chat buffer with the id of the user that is sending or receiving a message.
obj mysc.longpoll.event: an event wich defines some data from the vk's long poll server.""" obj mysc.longpoll.event: an event wich defines some data from the vk's long poll server."""
print obj
# Set user_id to the id of the friend wich is receiving or sending the message. # Set user_id to the id of the friend wich is receiving or sending the message.
obj.user_id = obj.from_id obj.user_id = obj.from_id
buffer = self.search_chat_buffer(obj.user_id) buffer = self.search_chat_buffer(obj.user_id)

View File

@ -296,6 +296,7 @@ class vkSession(object):
def get_messages(self, name="", *args, **kwargs): def get_messages(self, name="", *args, **kwargs):
data = self.vk.client.messages.getHistory(*args, **kwargs) data = self.vk.client.messages.getHistory(*args, **kwargs)
data["items"].reverse()
if data != None: if data != None:
num = self.order_buffer(name, data["items"], False) num = self.order_buffer(name, data["items"], False)
return num return num