Bug 1516423 - Have WinUnreadBadge own TaskbarWindowPreview. r=mkmelin
In Thunderbird, an instance of `TaskbarWindowPreview` is created when `WinUnreadBadge.updateUnreadCount` calls `WinTaskbar::GetOverlayIconController`. However, that instance is freed immdiately after `updateUnreadCount` exits because nobody owns it. As a result, the taskbar icon disappears even when `mail.minimizeToTray = false`. This patch makes `WinUnreadBadge` own a reference to `TaskbarWindowPreview` so that its instance is kept alive after the method exits. This approach is the same as Firefox stores `TaskbarWindowPreview` as `DownloadsTaskbar._taskbarProgress`. Differential Revision: https://phabricator.services.mozilla.com/D110191 --HG-- extra : amend_source : 6817b4fb4e049a3e5005505fbac5eae9994a404c
This commit is contained in:
Родитель
64705769ed
Коммит
f4732a845e
|
@ -184,6 +184,12 @@ function downsampleBy4X(window, canvas) {
|
|||
* A module to manage the unread badge icon on Windows.
|
||||
*/
|
||||
var WinUnreadBadge = {
|
||||
/**
|
||||
* Keeping an instance of nsITaskbarOverlayIconController alive
|
||||
* to show a taskbar icon after the updateUnreadCount method exits.
|
||||
*/
|
||||
_controller: null,
|
||||
|
||||
/**
|
||||
* Update the unread badge.
|
||||
* @param {number} unreadCount - Unread message count.
|
||||
|
@ -194,10 +200,12 @@ var WinUnreadBadge = {
|
|||
if (!window) {
|
||||
return;
|
||||
}
|
||||
let controller = taskbar.getOverlayIconController(window.docShell);
|
||||
if (!this._controller) {
|
||||
this._controller = taskbar.getOverlayIconController(window.docShell);
|
||||
}
|
||||
if (unreadCount == 0) {
|
||||
// Remove the badge if no unread.
|
||||
controller.setOverlayIcon(null, "");
|
||||
this._controller.setOverlayIcon(null, "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -228,6 +236,6 @@ var WinUnreadBadge = {
|
|||
// setOverlayIcon.
|
||||
await new Promise(resolve => window.setTimeout(resolve));
|
||||
|
||||
controller.setOverlayIcon(icon, unreadTooltip);
|
||||
this._controller.setOverlayIcon(icon, unreadTooltip);
|
||||
},
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче