Unread count refresh updates
This commit is contained in:
parent
66824c32d1
commit
4f56e49a30
|
@ -961,14 +961,18 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
xFolder = folder
|
xFolder = folder
|
||||||
if isinstance(item, Ui_FolderWidget):
|
if isinstance(item, Ui_FolderWidget):
|
||||||
xFolder = item.folderName
|
xFolder = item.folderName
|
||||||
|
if xFolder == "new":
|
||||||
|
xFolder = "inbox"
|
||||||
|
if addressItem.type == AccountMixin.ALL:
|
||||||
|
if xFolder:
|
||||||
|
queryreturn = sqlQuery("SELECT COUNT(*) FROM inbox WHERE folder = ? AND read = 0", xFolder)
|
||||||
|
else:
|
||||||
|
queryreturn = sqlQuery("SELECT COUNT(*) FROM inbox WHERE read = 0")
|
||||||
|
else:
|
||||||
if address and xFolder:
|
if address and xFolder:
|
||||||
queryreturn = sqlQuery("SELECT COUNT(*) FROM inbox WHERE " + xAddress + " = ? AND folder = ? AND read = 0", address, xFolder)
|
queryreturn = sqlQuery("SELECT COUNT(*) FROM inbox WHERE " + xAddress + " = ? AND folder = ? AND read = 0", address, xFolder)
|
||||||
elif address:
|
elif address:
|
||||||
queryreturn = sqlQuery("SELECT COUNT(*) FROM inbox WHERE " + xAddress + " = ? AND read = 0", address)
|
queryreturn = sqlQuery("SELECT COUNT(*) FROM inbox WHERE " + xAddress + " = ? AND read = 0", address)
|
||||||
elif xFolder:
|
|
||||||
queryreturn = sqlQuery("SELECT COUNT(*) FROM inbox WHERE folder = ? AND read = 0", xFolder)
|
|
||||||
else:
|
|
||||||
queryreturn = sqlQuery("SELECT COUNT(*) FROM inbox WHERE read = 0")
|
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
item.setUnreadCount(int(row[0]))
|
item.setUnreadCount(int(row[0]))
|
||||||
if isinstance(item, Ui_AddressWidget) and item.type == AccountMixin.ALL:
|
if isinstance(item, Ui_AddressWidget) and item.type == AccountMixin.ALL:
|
||||||
|
@ -983,9 +987,6 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.drawTrayIcon(self.currentTrayIconFileName, self.findInboxUnreadCount(self.unreadCount -1))
|
self.drawTrayIcon(self.currentTrayIconFileName, self.findInboxUnreadCount(self.unreadCount -1))
|
||||||
|
|
||||||
widgets = [self.ui.treeWidgetYourIdentities, self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans]
|
widgets = [self.ui.treeWidgetYourIdentities, self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans]
|
||||||
# FIXME this is a hack
|
|
||||||
if folder == "new":
|
|
||||||
folder = "inbox"
|
|
||||||
for treeWidget in widgets:
|
for treeWidget in widgets:
|
||||||
root = treeWidget.invisibleRootItem()
|
root = treeWidget.invisibleRootItem()
|
||||||
for i in range(root.childCount()):
|
for i in range(root.childCount()):
|
||||||
|
@ -998,13 +999,16 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
continue
|
continue
|
||||||
for j in range(addressItem.childCount()):
|
for j in range(addressItem.childCount()):
|
||||||
folderItem = addressItem.child(j)
|
folderItem = addressItem.child(j)
|
||||||
if folder is not None and folderItem.folderName != folder and addressItem.type != AccountMixin.ALL:
|
if folderItem.folderName == "new" and (folder is None or folder in ["inbox", "new"]):
|
||||||
|
updateUnreadCount(folderItem)
|
||||||
|
continue
|
||||||
|
if folder is None and folderItem.folderName != "inbox":
|
||||||
|
continue
|
||||||
|
if folder is not None and ((folder == "new" and folderItem.folderName != "inbox") or \
|
||||||
|
(folder != "new" and folderItem.folderName != folder)):
|
||||||
continue
|
continue
|
||||||
if addressItem.type == AccountMixin.ALL:
|
|
||||||
if folder in ["sent", "trash"] and folderItem.folderName != folder:
|
if folder in ["sent", "trash"] and folderItem.folderName != folder:
|
||||||
continue
|
continue
|
||||||
if folder in ["inbox", "new"] and folderItem.folderName not in ["inbox", "new"]:
|
|
||||||
continue
|
|
||||||
updateUnreadCount(folderItem)
|
updateUnreadCount(folderItem)
|
||||||
|
|
||||||
def addMessageListItem(self, tableWidget, items):
|
def addMessageListItem(self, tableWidget, items):
|
||||||
|
@ -3003,9 +3007,9 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
tableWidget.item(currentRow, 2).setUnread(True)
|
tableWidget.item(currentRow, 2).setUnread(True)
|
||||||
tableWidget.item(currentRow, 3).setFont(font)
|
tableWidget.item(currentRow, 3).setFont(font)
|
||||||
#sqlite requires the exact number of ?s to prevent injection
|
#sqlite requires the exact number of ?s to prevent injection
|
||||||
sqlExecute('''UPDATE inbox SET read=0 WHERE msgid IN (%s)''' % (
|
rowcount = sqlExecute('''UPDATE inbox SET read=0 WHERE msgid IN (%s) AND read=1''' % (
|
||||||
"?," * len(inventoryHashesToMarkUnread))[:-1], *inventoryHashesToMarkUnread)
|
"?," * len(inventoryHashesToMarkUnread))[:-1], *inventoryHashesToMarkUnread)
|
||||||
if modified == 1:
|
if rowcount == 1:
|
||||||
# performance optimisation
|
# performance optimisation
|
||||||
self.propagateUnreadCount(tableWidget.item(currentRow, 1 if tableWidget.item(currentRow, 1).type == AccountMixin.SUBSCRIPTION else 0).data(Qt.UserRole), self.getCurrentFolder())
|
self.propagateUnreadCount(tableWidget.item(currentRow, 1 if tableWidget.item(currentRow, 1).type == AccountMixin.SUBSCRIPTION else 0).data(Qt.UserRole), self.getCurrentFolder())
|
||||||
else:
|
else:
|
||||||
|
@ -4059,13 +4063,13 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
currentRow = tableWidget.currentRow()
|
currentRow = tableWidget.currentRow()
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
message, read = row
|
message, read = row
|
||||||
if folder != 'sent' and read == 0:
|
if tableWidget.item(currentRow, 0).unread == True:
|
||||||
markread = sqlQuery(
|
|
||||||
'''UPDATE inbox SET read = 1 WHERE msgid = ?''', msgid)
|
|
||||||
refresh = propagate = True
|
|
||||||
elif tableWidget.item(currentRow, 0).unread == True:
|
|
||||||
refresh = True
|
refresh = True
|
||||||
propagate = False
|
if folder != 'sent':
|
||||||
|
markread = sqlExecute(
|
||||||
|
'''UPDATE inbox SET read = 1 WHERE msgid = ? AND read=0''', msgid)
|
||||||
|
if markread > 0:
|
||||||
|
propagate = True
|
||||||
if refresh:
|
if refresh:
|
||||||
if not tableWidget:
|
if not tableWidget:
|
||||||
return
|
return
|
||||||
|
|
Reference in New Issue
Block a user