unsent files fix
This commit is contained in:
parent
0cfb8efefa
commit
019165aeac
@ -1,5 +1,6 @@
|
|||||||
import contact
|
import contact
|
||||||
from messages import *
|
from messages import *
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Friend(contact.Contact):
|
class Friend(contact.Contact):
|
||||||
@ -37,6 +38,15 @@ class Friend(contact.Contact):
|
|||||||
def clear_unsent_files(self):
|
def clear_unsent_files(self):
|
||||||
self._corr = list(filter(lambda x: type(x) is not UnsentFile, self._corr))
|
self._corr = list(filter(lambda x: type(x) is not UnsentFile, self._corr))
|
||||||
|
|
||||||
|
def remove_invalid_unsent_files(self):
|
||||||
|
def is_valid(message):
|
||||||
|
if type(message) is not UnsentFile:
|
||||||
|
return True
|
||||||
|
if message.get_data()[1] is not None:
|
||||||
|
return True
|
||||||
|
return os.path.exists(message.get_data()[0])
|
||||||
|
self._corr = list(filter(is_valid, self._corr))
|
||||||
|
|
||||||
def delete_one_unsent_file(self, time):
|
def delete_one_unsent_file(self, time):
|
||||||
self._corr = list(filter(lambda x: not (type(x) is UnsentFile and x.get_data()[2] == time), self._corr))
|
self._corr = list(filter(lambda x: not (type(x) is UnsentFile and x.get_data()[2] == time), self._corr))
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ PAGE_SIZE = 42
|
|||||||
|
|
||||||
TIMEOUT = 11
|
TIMEOUT = 11
|
||||||
|
|
||||||
SAVE_MESSAGES = 150
|
SAVE_MESSAGES = 250
|
||||||
|
|
||||||
MESSAGE_OWNER = {
|
MESSAGE_OWNER = {
|
||||||
'ME': 0,
|
'ME': 0,
|
||||||
|
@ -219,6 +219,7 @@ class Profile(basecontact.BaseContact, Singleton):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
friend = self._contacts[value]
|
friend = self._contacts[value]
|
||||||
|
friend.remove_invalid_unsent_files()
|
||||||
if self._active_friend != value:
|
if self._active_friend != value:
|
||||||
self._screen.messageEdit.setPlainText(friend.curr_text)
|
self._screen.messageEdit.setPlainText(friend.curr_text)
|
||||||
self._active_friend = value
|
self._active_friend = value
|
||||||
@ -329,6 +330,7 @@ class Profile(basecontact.BaseContact, Singleton):
|
|||||||
|
|
||||||
def send_files(self, friend_number):
|
def send_files(self, friend_number):
|
||||||
friend = self.get_friend_by_number(friend_number)
|
friend = self.get_friend_by_number(friend_number)
|
||||||
|
friend.remove_invalid_unsent_files()
|
||||||
files = friend.get_unsent_files()
|
files = friend.get_unsent_files()
|
||||||
try:
|
try:
|
||||||
for fl in files:
|
for fl in files:
|
||||||
|
Loading…
Reference in New Issue
Block a user