Updated code to handle unread messsages

This commit is contained in:
Manuel Cortez 2018-12-20 15:36:32 -06:00
parent e3dae698d9
commit ba14699dfb
2 changed files with 6 additions and 0 deletions

View File

@ -858,6 +858,11 @@ class chatBuffer(baseBuffer):
else:
log.debug("Unhandled attachment: %r" % (attachment,))
def clear_reads(self):
for i in self.session.db[self.name]["items"]:
if "read_state" in i and i["read_state"] == 0:
i["read_state"] = 1
class peopleBuffer(feedBuffer):
def create_tab(self, parent):

View File

@ -479,6 +479,7 @@ class Controller(object):
for i in self.buffers:
if hasattr(i, "reads") and len(i.reads) != 0:
response = self.session.vk.client.messages.markAsRead(peer_id=i.kwargs["user_id"])
i.clear_reads()
i.reads = []
time.sleep(1)