mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug #75866 --> Mark a message as read in JS instead of once for each mail protocol to simplify code.
Hookup the JS function to a timer to allow users to only mark messages as read after they have been viewed in the preview pane for a configurable number of seconds. sr=bienvenu
This commit is contained in:
parent
7cbc0c61b9
commit
591ef7cdf0
@ -306,6 +306,9 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder)
|
||||
gDBView = null;
|
||||
}
|
||||
|
||||
// cancel the pending mark as read timer
|
||||
ClearPendingReadTimer();
|
||||
|
||||
// if this is the drafts, sent, or send later folder,
|
||||
// we show "Recipient" instead of "Author"
|
||||
SetSentFolderColumns(IsSpecialFolder(newFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE));
|
||||
|
@ -469,10 +469,22 @@ var DefaultController =
|
||||
break;// This does nothing because the createfilter is invoked from the popupnode oncommand.
|
||||
case "button_delete":
|
||||
case "cmd_delete":
|
||||
// if the user deletes a message before its mark as read timer goes off, we should mark it as read
|
||||
// this ensures that we clear the biff indicator from the system tray when the user deletes the new message
|
||||
if (gMarkViewedMessageAsReadTimer)
|
||||
{
|
||||
MarkCurrentMessageAsRead();
|
||||
ClearPendingReadTimer();
|
||||
}
|
||||
SetNextMessageAfterDelete();
|
||||
gDBView.doCommand(nsMsgViewCommandType.deleteMsg);
|
||||
break;
|
||||
case "cmd_shiftDelete":
|
||||
if (gMarkViewedMessageAsReadTimer)
|
||||
{
|
||||
MarkCurrentMessageAsRead();
|
||||
ClearPendingReadTimer();
|
||||
}
|
||||
SetNextMessageAfterDelete();
|
||||
gDBView.doCommand(nsMsgViewCommandType.deleteNoTrash);
|
||||
break;
|
||||
|
@ -72,6 +72,7 @@ var gLastKeywords = "";
|
||||
function OnMailWindowUnload()
|
||||
{
|
||||
RemoveMailOfflineObserver();
|
||||
ClearPendingReadTimer();
|
||||
|
||||
var searchSession = GetSearchSession();
|
||||
if (searchSession)
|
||||
|
@ -43,6 +43,7 @@ var gWindowManagerInterface;
|
||||
var gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||
var gPrintSettings = null;
|
||||
var gWindowReuse = 0;
|
||||
var gMarkViewedMessageAsReadTimer = null; // if the user has configured the app to mark a message as read if it is viewed for more than n seconds
|
||||
|
||||
var gTimelineService = null;
|
||||
var gTimelineEnabled = ("@mozilla.org;timeline-service;1" in Components.classes);
|
||||
@ -2069,6 +2070,20 @@ function SetUpJunkBar(aMsgHdr)
|
||||
goUpdateCommand('button_junk');
|
||||
}
|
||||
|
||||
function MarkCurrentMessageAsRead()
|
||||
{
|
||||
gDBView.doCommand(nsMsgViewCommandType.markMessagesRead);
|
||||
}
|
||||
|
||||
function ClearPendingReadTimer()
|
||||
{
|
||||
if (gMarkViewedMessageAsReadTimer)
|
||||
{
|
||||
clearTimeout(gMarkViewedMessageAsReadTimer);
|
||||
gMarkViewedMessageAsReadTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
function OnMsgLoaded(aUrl)
|
||||
{
|
||||
if (!aUrl)
|
||||
@ -2076,6 +2091,7 @@ function OnMsgLoaded(aUrl)
|
||||
|
||||
var folder = aUrl.folder;
|
||||
var msgURI = GetLoadedMessage();
|
||||
var msgHdr = null;
|
||||
|
||||
if (!folder || !msgURI)
|
||||
return;
|
||||
@ -2084,10 +2100,24 @@ function OnMsgLoaded(aUrl)
|
||||
SetUpJunkBar(null);
|
||||
else
|
||||
{
|
||||
var msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
||||
msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
||||
SetUpJunkBar(msgHdr);
|
||||
}
|
||||
|
||||
// we just finished loading a message. set a timer to actually mark the message is read after n seconds
|
||||
// where n can be configured by the user.
|
||||
|
||||
var markReadOnADelay = gPrefs.getBoolPref("mailnews.mark_message_read.delay");
|
||||
|
||||
if (msgHdr && !msgHdr.isRead)
|
||||
{
|
||||
var wintype = document.firstChild.getAttribute('windowtype');
|
||||
if (markReadOnADelay && wintype == "mail:3pane") // only use the timer if viewing using the 3-pane preview pane and the user has set the pref
|
||||
gMarkViewedMessageAsReadTimer = setTimeout(MarkCurrentMessageAsRead, gPrefs.getIntPref("mailnews.mark_message_read.delay.interval") * 1000);
|
||||
else
|
||||
MarkCurrentMessageAsRead();
|
||||
}
|
||||
|
||||
// See if MDN was requested but has not been sent.
|
||||
HandleMDNResponse(aUrl);
|
||||
|
||||
|
@ -172,6 +172,7 @@ nsMsgDBViewCommandUpdater.prototype =
|
||||
displayMessageChanged : function(aFolder, aSubject, aKeywords)
|
||||
{
|
||||
setTitleFromFolder(aFolder, aSubject);
|
||||
ClearPendingReadTimer(); // we are loading / selecting a new message so kill the mark as read timer for the currently viewed message
|
||||
gCurrentMessageUri = gDBView.URIForFirstSelectedMessage;
|
||||
UpdateStandAloneMessageCounts();
|
||||
SetKeywords(aKeywords);
|
||||
|
@ -125,13 +125,11 @@
|
||||
|
||||
<!-- Message Display Extras -->
|
||||
<expander id="generalSettings" label="&generalSettings.label;" open="true" persist="open" clearhidden="true">
|
||||
#ifdef 0
|
||||
<hbox align="center" pack="start">
|
||||
<checkbox id="markAsRead" label="&markAsRead.label;" prefstring="mailnews.mark_message_read.delay"/>
|
||||
<textbox id="markAsReadDelay" size="2" preftype="int" prefstring="mailnews.mark_message_read.delay.interval"/>
|
||||
<label value="&markAsReadEnd.label;"/>
|
||||
</hbox>
|
||||
#endif
|
||||
<hbox align="center" pack="start">
|
||||
<checkbox id="showFolderPaneColumns" label="&showFolderColumns.label;" prefstring="mail.showFolderPaneColumns"/>
|
||||
</hbox>
|
||||
|
Loading…
Reference in New Issue
Block a user