some messages improvements
This commit is contained in:
parent
f897c7ce8d
commit
3ef581bc5d
@ -30,7 +30,6 @@ class Contact(basecontact.BaseContact):
|
|||||||
self._corr = []
|
self._corr = []
|
||||||
self._unsaved_messages = 0
|
self._unsaved_messages = 0
|
||||||
self._history_loaded = self._new_actions = False
|
self._history_loaded = self._new_actions = False
|
||||||
self._receipts = 0
|
|
||||||
self._curr_text = self._search_string = ''
|
self._curr_text = self._search_string = ''
|
||||||
self._search_index = 0
|
self._search_index = 0
|
||||||
|
|
||||||
@ -140,12 +139,15 @@ class Contact(basecontact.BaseContact):
|
|||||||
"""
|
"""
|
||||||
Delete old messages (reduces RAM usage if messages saving is not enabled)
|
Delete old messages (reduces RAM usage if messages saving is not enabled)
|
||||||
"""
|
"""
|
||||||
old = filter(lambda x: x.get_type() == 2 and (x.get_status() >= 2 or x.get_status() is None),
|
def save_message(x):
|
||||||
self._corr[:-SAVE_MESSAGES])
|
if x.get_type() == 2 and (x.get_status() >= 2 or x.get_status() is None):
|
||||||
old = list(old)
|
return True
|
||||||
l = max(len(self._corr) - SAVE_MESSAGES, 0) - len(old)
|
return x.get_owner() == MESSAGE_OWNER['NOT_SENT']
|
||||||
self._unsaved_messages -= l
|
|
||||||
self._corr = old + self._corr[-SAVE_MESSAGES:]
|
old = filter(save_message, self._corr[:-SAVE_MESSAGES])
|
||||||
|
self._corr = list(old) + self._corr[-SAVE_MESSAGES:]
|
||||||
|
text_messages = filter(lambda x: x.get_type <= 1, self._corr)
|
||||||
|
self._unsaved_messages = min(self._unsaved_messages, len(list(text_messages)))
|
||||||
self._search_index = 0
|
self._search_index = 0
|
||||||
|
|
||||||
def clear_corr(self, save_unsent=False):
|
def clear_corr(self, save_unsent=False):
|
||||||
|
@ -412,8 +412,8 @@ class Profile(basecontact.BaseContact, Singleton):
|
|||||||
for message in messages:
|
for message in messages:
|
||||||
self.split_and_send(friend_number, message.get_data()[-1], message.get_data()[0].encode('utf-8'))
|
self.split_and_send(friend_number, message.get_data()[-1], message.get_data()[0].encode('utf-8'))
|
||||||
friend.inc_receipts()
|
friend.inc_receipts()
|
||||||
except:
|
except Exception as ex:
|
||||||
pass
|
log('Sending pending messages failed with ' + str(ex))
|
||||||
|
|
||||||
def split_and_send(self, number, message_type, message):
|
def split_and_send(self, number, message_type, message):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user