mirror of
https://github.com/Ximi1970/systray-x.git
synced 2025-11-09 14:56:07 +01:00
Enable new new mail for TB91+
This commit is contained in:
@@ -602,7 +602,7 @@ void PreferencesDialog::slotBrowserVersion()
|
|||||||
{
|
{
|
||||||
QString version = m_pref->getBrowserVersion();
|
QString version = m_pref->getBrowserVersion();
|
||||||
|
|
||||||
if( version.section( '.', 0, 0 ).toInt() > 89 && version.section( '.', 0, 0 ).toInt() < 102)
|
if( version.section( '.', 0, 0 ).toInt() > 89 && version.section( '.', 0, 0 ).toInt() < 91)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Hide the count type for TB90 and up, not supported
|
* Hide the count type for TB90 and up, not supported
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ SysTrayX.Info = {
|
|||||||
SysTrayX.Messaging = {
|
SysTrayX.Messaging = {
|
||||||
accounts: [],
|
accounts: [],
|
||||||
folderTree: {},
|
folderTree: {},
|
||||||
countType: 0,
|
countType: "0",
|
||||||
closeType: 1,
|
closeType: "1",
|
||||||
filters: undefined,
|
filters: undefined,
|
||||||
unread: {},
|
unread: {},
|
||||||
new: {},
|
new: {},
|
||||||
@@ -146,7 +146,7 @@ SysTrayX.Messaging = {
|
|||||||
SysTrayX.Messaging.listenerFolderDeleted
|
SysTrayX.Messaging.listenerFolderDeleted
|
||||||
);
|
);
|
||||||
|
|
||||||
if (SysTrayX.Messaging.countType === 0) {
|
if (SysTrayX.Messaging.countType === "0") {
|
||||||
// Get the unread count
|
// Get the unread count
|
||||||
const getCountUnreadPromise = () =>
|
const getCountUnreadPromise = () =>
|
||||||
new Promise((res) => res(SysTrayX.Messaging.countUnread()));
|
new Promise((res) => res(SysTrayX.Messaging.countUnread()));
|
||||||
@@ -164,6 +164,11 @@ SysTrayX.Messaging = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Catch a folder change to reset the new counter
|
||||||
|
browser.mailTabs.onDisplayedFolderChanged.addListener(
|
||||||
|
SysTrayX.Window.folderChanged
|
||||||
|
);
|
||||||
|
|
||||||
// Try to catch the window state
|
// Try to catch the window state
|
||||||
browser.windows.onFocusChanged.addListener(SysTrayX.Window.focusChanged);
|
browser.windows.onFocusChanged.addListener(SysTrayX.Window.focusChanged);
|
||||||
},
|
},
|
||||||
@@ -192,7 +197,7 @@ SysTrayX.Messaging = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SysTrayX.Messaging.countType === 1) {
|
if (SysTrayX.Messaging.countType === "1") {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
SysTrayX.Messaging.filters.forEach((filter) => {
|
SysTrayX.Messaging.filters.forEach((filter) => {
|
||||||
const accountId = filter.accountId;
|
const accountId = filter.accountId;
|
||||||
@@ -205,6 +210,7 @@ SysTrayX.Messaging = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.debug("listenerNewMail: New count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -229,18 +235,15 @@ SysTrayX.Messaging = {
|
|||||||
deleteFolderFromFilters(deletedFolder);
|
deleteFolderFromFilters(deletedFolder);
|
||||||
},
|
},
|
||||||
|
|
||||||
listenerFolderInfoChanged: function (folder, folderInfo) {
|
listenerFolderInfoChanged: async function (folder, folderInfo) {
|
||||||
console.debug("FolderInfoChanged: " + JSON.stringify(folder));
|
// console.debug("FolderInfoChanged: " + JSON.stringify(folder));
|
||||||
console.debug("FolderInfoChanged: " + JSON.stringify(folderInfo));
|
// console.debug("FolderInfoChanged: " + JSON.stringify(folderInfo));
|
||||||
|
|
||||||
if (folderInfo.unreadMessageCount !== undefined) {
|
if (folderInfo.unreadMessageCount !== undefined) {
|
||||||
if (SysTrayX.Messaging.unread[folder.accountId] === undefined) {
|
if (SysTrayX.Messaging.unread[folder.accountId] === undefined) {
|
||||||
SysTrayX.Messaging.unread[folder.accountId] = {};
|
SysTrayX.Messaging.unread[folder.accountId] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
SysTrayX.Messaging.unread[folder.accountId][folder.path] =
|
|
||||||
folderInfo.unreadMessageCount;
|
|
||||||
|
|
||||||
if (SysTrayX.Messaging.new[folder.accountId] === undefined) {
|
if (SysTrayX.Messaging.new[folder.accountId] === undefined) {
|
||||||
SysTrayX.Messaging.new[folder.accountId] = {};
|
SysTrayX.Messaging.new[folder.accountId] = {};
|
||||||
}
|
}
|
||||||
@@ -248,9 +251,11 @@ SysTrayX.Messaging = {
|
|||||||
if (SysTrayX.Messaging.new[folder.accountId][folder.path] === undefined) {
|
if (SysTrayX.Messaging.new[folder.accountId][folder.path] === undefined) {
|
||||||
SysTrayX.Messaging.new[folder.accountId][folder.path] = [];
|
SysTrayX.Messaging.new[folder.accountId][folder.path] = [];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (SysTrayX.Messaging.countType === 0) {
|
SysTrayX.Messaging.unread[folder.accountId][folder.path] =
|
||||||
|
folderInfo.unreadMessageCount;
|
||||||
|
|
||||||
|
if (SysTrayX.Messaging.countType === "0") {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
SysTrayX.Messaging.filters.forEach((filter) => {
|
SysTrayX.Messaging.filters.forEach((filter) => {
|
||||||
const accountId = filter.accountId;
|
const accountId = filter.accountId;
|
||||||
@@ -263,28 +268,28 @@ SysTrayX.Messaging = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.debug("listenerFolderInfoChanged: Unread count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: 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];
|
||||||
|
|
||||||
console.debug("Messages: " + JSON.stringify(messages));
|
if (messages.length > 0) {
|
||||||
|
|
||||||
const newMessages = [];
|
const newMessages = [];
|
||||||
messages.forEach(async (message) => {
|
for (let i = 0; i < messages.length; ++i) {
|
||||||
console.debug("Message Id: " + message.id);
|
const message = messages[i];
|
||||||
|
|
||||||
const header = await browser.messages.get(message.id);
|
const getHeaderPromise = (messageId) =>
|
||||||
|
new Promise((res) => res(messenger.messages.get(messageId)));
|
||||||
console.debug("Header: " + JSON.stringify(header));
|
const header = await getHeaderPromise(message.id);
|
||||||
|
|
||||||
if (!header.read) {
|
if (!header.read) {
|
||||||
newMessages.push(message);
|
newMessages.push(message);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
SysTrayX.Messaging.new[folder.accountId][folder.path] = newMessages;
|
SysTrayX.Messaging.new[folder.accountId][folder.path] = [
|
||||||
|
...newMessages,
|
||||||
console.debug("New Messages: " + JSON.stringify(newMessages));
|
];
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
SysTrayX.Messaging.filters.forEach((filter) => {
|
SysTrayX.Messaging.filters.forEach((filter) => {
|
||||||
@@ -292,14 +297,18 @@ SysTrayX.Messaging = {
|
|||||||
filter.folders.forEach((path) => {
|
filter.folders.forEach((path) => {
|
||||||
if (SysTrayX.Messaging.new[accountId] !== undefined) {
|
if (SysTrayX.Messaging.new[accountId] !== undefined) {
|
||||||
if (SysTrayX.Messaging.new[accountId][path] !== undefined) {
|
if (SysTrayX.Messaging.new[accountId][path] !== undefined) {
|
||||||
count = count + SysTrayX.Messaging.new[accountId][path].length;
|
count =
|
||||||
|
count + SysTrayX.Messaging.new[accountId][path].length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.debug("listenerFolderInfoChanged: New count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
countUnread: async function () {
|
countUnread: async function () {
|
||||||
@@ -336,6 +345,7 @@ SysTrayX.Messaging = {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// console.debug("countUnread: Unread count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -379,6 +389,7 @@ SysTrayX.Messaging = {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// console.debug("countNew: New count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -403,7 +414,7 @@ SysTrayX.Messaging = {
|
|||||||
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
if (SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||||
browser.folderChange.setFilters(SysTrayX.Messaging.filters);
|
browser.folderChange.setFilters(SysTrayX.Messaging.filters);
|
||||||
} else {
|
} else {
|
||||||
if (SysTrayX.Messaging.countType === 0) {
|
if (SysTrayX.Messaging.countType === "0") {
|
||||||
// Update unread count
|
// Update unread count
|
||||||
const getCountUnreadPromise = () =>
|
const getCountUnreadPromise = () =>
|
||||||
new Promise((res) => res(SysTrayX.Messaging.countUnread()));
|
new Promise((res) => res(SysTrayX.Messaging.countUnread()));
|
||||||
@@ -458,6 +469,7 @@ SysTrayX.Messaging = {
|
|||||||
// Callback for unReadMessages
|
// Callback for unReadMessages
|
||||||
//
|
//
|
||||||
unreadCb: function (count) {
|
unreadCb: function (count) {
|
||||||
|
// console.debug("unreadCb: Unread/New count");
|
||||||
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -898,6 +910,46 @@ SysTrayX.Window = {
|
|||||||
SysTrayX.Link.postSysTrayXMessage({ window: win.state });
|
SysTrayX.Link.postSysTrayXMessage({ window: win.state });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
folderChanged: function (tab, displayedFolder) {
|
||||||
|
/*
|
||||||
|
console.debug("Folder changed tab: " + JSON.stringify(tab));
|
||||||
|
console.debug(
|
||||||
|
"Folder changed displayFolder: " + JSON.stringify(displayedFolder)
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
// console.debug("New storage: " + JSON.stringify(SysTrayX.Messaging.new));
|
||||||
|
|
||||||
|
// Clear all other new items except this one for this account
|
||||||
|
// to emulate TBs new handling
|
||||||
|
//
|
||||||
|
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") {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.debug("listenerNewMail: New count");
|
||||||
|
SysTrayX.Link.postSysTrayXMessage({ unreadMail: count });
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
|
|||||||
@@ -1178,7 +1178,7 @@ async function start() {
|
|||||||
SysTrayX.Info.version;
|
SysTrayX.Info.version;
|
||||||
|
|
||||||
// Disable incompatible items
|
// Disable incompatible items
|
||||||
if (SysTrayX.Info.browserInfo.majorVersion > 89 && SysTrayX.Info.browserInfo.majorVersion < 102) {
|
if (SysTrayX.Info.browserInfo.majorVersion > 89 && SysTrayX.Info.browserInfo.majorVersion < 91) {
|
||||||
document.getElementById("counttype").style.display = "none";
|
document.getElementById("counttype").style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user