Attempt to fix problem when a message is not detected as unread

This commit is contained in:
Manuel Cortez 2019-01-16 17:54:29 -06:00
parent 82ed352c1d
commit 8b0070efd4
2 changed files with 2 additions and 3 deletions

View File

@ -821,7 +821,6 @@ class chatBuffer(baseBuffer):
self.session.soundplayer.play("message_unread.ogg") self.session.soundplayer.play("message_unread.ogg")
self.reads.append(msg["id"]) self.reads.append(msg["id"])
self.session.db[self.name]["items"][-1]["read_state"] = 1 self.session.db[self.name]["items"][-1]["read_state"] = 1
# print msg
if "attachments" in msg and len(msg["attachments"]) > 0: if "attachments" in msg and len(msg["attachments"]) > 0:
self.tab.attachments.list.Enable(True) self.tab.attachments.list.Enable(True)
self.attachments = list() self.attachments = list()

View File

@ -419,15 +419,15 @@ class Controller(object):
# If the chat already exists, let's create a dictionary wich will contains data of the received message. # If the chat already exists, let's create a dictionary wich will contains data of the received message.
message.update(id=obj.message_id, user_id=uid, date=obj.timestamp, body=obj.text, attachments=obj.attachments) message.update(id=obj.message_id, user_id=uid, date=obj.timestamp, body=obj.text, attachments=obj.attachments)
# if attachments is true, let's request for the full message with attachments formatted in a better way. # if attachments is true, let's request for the full message with attachments formatted in a better way.
# Todo: code improvements. We shouldn't need to request the same message again just for these attachments. # ToDo: code improvements. We shouldn't need to request the same message again just for these attachments.
if len(message["attachments"]) != 0: if len(message["attachments"]) != 0:
message_ids = message["id"] message_ids = message["id"]
results = self.session.vk.client.messages.getById(message_ids=message_ids) results = self.session.vk.client.messages.getById(message_ids=message_ids)
message = results["items"][0] message = results["items"][0]
message.update(read_state=0)
if obj.from_me: if obj.from_me:
message["from_id"] = self.session.user_id message["from_id"] = self.session.user_id
else: else:
message.update(read_state=0)
message["from_id"] = obj.user_id message["from_id"] = obj.user_id
data = [message] data = [message]
# Let's add this to the buffer. # Let's add this to the buffer.