offline messaging part 2 - read receipts

This commit is contained in:
ingvar1995 2016-06-04 22:41:03 +03:00
parent 42617c8816
commit d02ee92508
2 changed files with 22 additions and 5 deletions

View file

@ -144,6 +144,7 @@ class Friend(Contact):
self._corr = []
self._unsaved_messages = 0
self._history_loaded = False
self._receipts = 0
def __del__(self):
self.set_visibility(False)
@ -155,6 +156,19 @@ class Friend(Contact):
# History support
# -----------------------------------------------------------------------------------------------------------------
def get_receipts(self):
return self._receipts
receipts = property(get_receipts)
def inc_receipts(self):
self._receipts += 1
def dec_receipt(self):
if self._receipts:
self._receipts -= 1
self.mark_as_sent(False)
def load_corr(self, first_time=True):
"""
:param first_time: friend became active, load first part of messages
@ -608,13 +622,11 @@ class Profile(Contact, Singleton):
friend = self._friends[self._active_friend]
if friend.status is not None:
self.split_and_send(friend.number, message_type, text.encode('utf-8'))
owner = MESSAGE_OWNER['ME']
else:
owner = MESSAGE_OWNER['NOT_SENT']
self.create_message_item(text, curr_time(), self._name, message_type)
self._screen.messageEdit.clear()
self._messages.scrollToBottom()
friend.append_message(TextMessage(text, owner, time.time(), message_type))
friend.append_message(TextMessage(text, MESSAGE_OWNER['NOT_SENT'], time.time(), message_type))
friend.inc_receipts()
# -----------------------------------------------------------------------------------------------------------------
# History support