Improvement to unread messages: Mark as unread only messages sent by another user
This commit is contained in:
parent
9296ef5333
commit
977dcb7dc3
@ -700,7 +700,7 @@ class chatBuffer(baseBuffer):
|
||||
msg = self.get_focused_post()
|
||||
if msg == False: # Handle the case where the last line of the control cannot be matched to anything.
|
||||
return
|
||||
if msg.has_key("read_state") and msg["read_state"] == 0 and msg["id"] not in self.reads:
|
||||
if msg.has_key("read_state") and msg["read_state"] == 0 and msg["id"] not in self.reads and msg.has_key("out") and msg["out"] == 0:
|
||||
self.session.soundplayer.play("message_unread.ogg")
|
||||
self.reads.append(msg["id"])
|
||||
self.session.db[self.name]["items"][-1]["read_state"] = 1
|
||||
|
@ -406,10 +406,12 @@ class Controller(object):
|
||||
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.
|
||||
obj vk_api.longpoll.EventType: an event wich defines some data from the vk's long poll server."""
|
||||
message = {}
|
||||
# If someone else sends a message to the current user.
|
||||
if obj.to_me:
|
||||
buffer = self.search_chat_buffer(obj.user_id)
|
||||
uid = obj.user_id
|
||||
message.update(out=0)
|
||||
# If the current user sends a message to someone else.
|
||||
else:
|
||||
buffer = self.search_chat_buffer(obj.peer_id)
|
||||
@ -420,7 +422,7 @@ class Controller(object):
|
||||
self.session.soundplayer.play("conversation_opened.ogg")
|
||||
return
|
||||
# If the chat already exists, let's create a dictionary wich will contains data of the received message.
|
||||
message = {"id": obj.message_id, "user_id": uid, "date": obj.timestamp, "body": obj.text, "attachments": obj.attachments, "read_state": 0}
|
||||
message.update(id=obj.message_id, user_id=uid, date=obj.timestamp, body=obj.text, attachments=obj.attachments, read_state=0)
|
||||
# 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.
|
||||
if len(message["attachments"]) != 0:
|
||||
|
Loading…
Reference in New Issue
Block a user