mirror of
https://github.com/Ximi1970/systray-x.git
synced 2025-11-15 17:56:09 +01:00
Try to match the new mail flag clear of TB102.0b7
This commit is contained in:
@@ -27,6 +27,7 @@ SysTrayX.Messaging = {
|
|||||||
filters: undefined,
|
filters: undefined,
|
||||||
unread: {},
|
unread: {},
|
||||||
new: {},
|
new: {},
|
||||||
|
displayedFolder: undefined,
|
||||||
|
|
||||||
init: async function () {
|
init: async function () {
|
||||||
// Send the startup positions?
|
// Send the startup positions?
|
||||||
@@ -198,20 +199,8 @@ SysTrayX.Messaging = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SysTrayX.Messaging.countType === "1") {
|
if (SysTrayX.Messaging.countType === "1") {
|
||||||
let count = 0;
|
getNewMailCount();
|
||||||
SysTrayX.Messaging.filters.forEach((filter) => {
|
|
||||||
const accountId = filter.accountId;
|
|
||||||
filter.folders.forEach((path) => {
|
|
||||||
if (SysTrayX.Messaging.new[accountId] !== undefined) {
|
|
||||||
if (SysTrayX.Messaging.new[accountId][path] !== undefined) {
|
|
||||||
count = count + SysTrayX.Messaging.new[accountId][path].length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.debug("listenerNewMail: New count");
|
// console.debug("listenerNewMail: New count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -256,20 +245,8 @@ SysTrayX.Messaging = {
|
|||||||
folderInfo.unreadMessageCount;
|
folderInfo.unreadMessageCount;
|
||||||
|
|
||||||
if (SysTrayX.Messaging.countType === "0") {
|
if (SysTrayX.Messaging.countType === "0") {
|
||||||
let count = 0;
|
getUnreadMailCount();
|
||||||
SysTrayX.Messaging.filters.forEach((filter) => {
|
|
||||||
const accountId = filter.accountId;
|
|
||||||
filter.folders.forEach((path) => {
|
|
||||||
if (SysTrayX.Messaging.unread[accountId] !== undefined) {
|
|
||||||
if (SysTrayX.Messaging.unread[accountId][path] !== undefined) {
|
|
||||||
count = count + SysTrayX.Messaging.unread[accountId][path];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.debug("listenerFolderInfoChanged: Unread count");
|
// console.debug("listenerFolderInfoChanged: Unread count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
|
||||||
} else {
|
} else {
|
||||||
// Check if the new mails have been read, remove from new storage
|
// Check if the new mails have been read, remove from new storage
|
||||||
const messages = SysTrayX.Messaging.new[folder.accountId][folder.path];
|
const messages = SysTrayX.Messaging.new[folder.accountId][folder.path];
|
||||||
@@ -291,21 +268,8 @@ SysTrayX.Messaging = {
|
|||||||
...newMessages,
|
...newMessages,
|
||||||
];
|
];
|
||||||
|
|
||||||
let count = 0;
|
getNewMailCount();
|
||||||
SysTrayX.Messaging.filters.forEach((filter) => {
|
|
||||||
const accountId = filter.accountId;
|
|
||||||
filter.folders.forEach((path) => {
|
|
||||||
if (SysTrayX.Messaging.new[accountId] !== undefined) {
|
|
||||||
if (SysTrayX.Messaging.new[accountId][path] !== undefined) {
|
|
||||||
count =
|
|
||||||
count + SysTrayX.Messaging.new[accountId][path].length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.debug("listenerFolderInfoChanged: New count");
|
// console.debug("listenerFolderInfoChanged: New count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -912,43 +876,27 @@ SysTrayX.Window = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
folderChanged: function (tab, displayedFolder) {
|
folderChanged: function (tab, displayedFolder) {
|
||||||
/*
|
/*
|
||||||
console.debug("Folder changed tab: " + JSON.stringify(tab));
|
console.debug("Folder changed tab: " + JSON.stringify(tab));
|
||||||
console.debug(
|
console.debug(
|
||||||
"Folder changed displayFolder: " + JSON.stringify(displayedFolder)
|
"Folder changed displayedFolder: " + JSON.stringify(displayedFolder)
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
// console.debug("New storage: " + JSON.stringify(SysTrayX.Messaging.new));
|
const oldDisplayedFolder = SysTrayX.Messaging.displayedFolder;
|
||||||
|
if (oldDisplayedFolder !== undefined) {
|
||||||
// Clear all other new items except this one for this account
|
if (oldDisplayedFolder.accountId === displayedFolder.accountId) {
|
||||||
// to emulate TBs new handling
|
SysTrayX.Messaging.new[oldDisplayedFolder.accountId][
|
||||||
//
|
oldDisplayedFolder.path
|
||||||
Object.keys(SysTrayX.Messaging.new).forEach((accountId) => {
|
] = [];
|
||||||
console.debug("Testing: " + accountId);
|
|
||||||
if (accountId !== displayedFolder.accountId) {
|
|
||||||
SysTrayX.Messaging.new[accountId] = undefined;
|
|
||||||
console.debug("Removed: " + accountId);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// console.debug("New storage cleaned: " + JSON.stringify(SysTrayX.Messaging.new));
|
|
||||||
|
|
||||||
if (SysTrayX.Messaging.countType === "1") {
|
if (SysTrayX.Messaging.countType === "1") {
|
||||||
let count = 0;
|
getNewMailCount();
|
||||||
SysTrayX.Messaging.filters.forEach((filter) => {
|
|
||||||
const accountId = filter.accountId;
|
|
||||||
filter.folders.forEach((path) => {
|
|
||||||
if (SysTrayX.Messaging.new[accountId] !== undefined) {
|
|
||||||
if (SysTrayX.Messaging.new[accountId][path] !== undefined) {
|
|
||||||
count = count + SysTrayX.Messaging.new[accountId][path].length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.debug("listenerNewMail: New count");
|
// console.debug("listenerNewMail: New count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SysTrayX.Messaging.displayedFolder = displayedFolder;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -363,3 +363,38 @@ async function addFolderToFilters(newFolder) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count the unread mail
|
||||||
|
const getUnreadMailCount = () => {
|
||||||
|
let count = 0;
|
||||||
|
SysTrayX.Messaging.filters.forEach((filter) => {
|
||||||
|
const accountId = filter.accountId;
|
||||||
|
filter.folders.forEach((path) => {
|
||||||
|
if (SysTrayX.Messaging.unread[accountId] !== undefined) {
|
||||||
|
if (SysTrayX.Messaging.unread[accountId][path] !== undefined) {
|
||||||
|
count = count + SysTrayX.Messaging.unread[accountId][path];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count the new mail
|
||||||
|
const getNewMailCount = () => {
|
||||||
|
let count = 0;
|
||||||
|
SysTrayX.Messaging.filters.forEach((filter) => {
|
||||||
|
const accountId = filter.accountId;
|
||||||
|
filter.folders.forEach((path) => {
|
||||||
|
if (SysTrayX.Messaging.new[accountId] !== undefined) {
|
||||||
|
if (SysTrayX.Messaging.new[accountId][path] !== undefined) {
|
||||||
|
count = count + SysTrayX.Messaging.new[accountId][path].length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user