Closed Bug 786200 Opened 12 years ago Closed 12 years ago

Remove use of GetFirstSelectedMessage


(SeaMonkey :: MailNews: Message Display, defect)

Not set


(seamonkey2.15 fixed)

Tracking Status
seamonkey2.15 --- fixed


(Reporter: iannbugzilla, Assigned: iannbugzilla)


(Blocks 1 open bug)



(1 file, 1 obsolete file)

Attached patch Use selectedMessage[Uris] (obsolete) — Splinter Review
Bug 517238 introduced both selectedMessage and selectedMessageUris which means the removal of GetFirstSelectedMessage can be ported from bug 474701 and switching from gDBView.hdrForFirstSelectedMessage to gFolderDisplay.selectedMessage can be started.
Changing of the function SelectedMessagesAreRead will be covered in bug 768025.
Attachment #655933 - Flags: review?(neil)
Comment on attachment 655933 [details] [diff] [review]
Use selectedMessage[Uris]

>-  var aMessage = GetFirstSelectedMessage();
>+  var aMessage = gFolderDisplay.selectedMessage;
[This was confusing! Fortunately only the value is only used as a boolean.]

> function ToggleMessageTagKey(index)
> {
>   if (GetNumSelectedMessages() < 1)
>     return;
>   // toggle the tag state based upon that of the first selected message
>-  var msgHdr = gDBView.hdrForFirstSelectedMessage;
>+  var msgHdr = gFolderDisplay.selectedMessage;
Nit: This ends up checking the number of selected messages twice. Better to get the selected message and bail out if it is null.

>+function SelectedMessagesAreJunk()
>+  try {
>+    var junkScore = gFolderDisplay.selectedMessage.getStringProperty("junkscore");
>+    return (junkScore != "") && (junkScore != "0");
>   }
>+  catch (ex) {
>     return false;
>   }
> }
The only thing that can throw here is if selectedMessage is null, so check that instead. r=me with that fixed.

>-function SelectedMessagesAreJunk()
[diff, WTF?]

>+    SaveAsTemplate(gFolderDisplay.selectedMessageUris[0]);
>+    messageUri = gFolderDisplay.selectedMessageUris[0];
-function GetFirstSelectedMessage()
-    try {
-        return gDBView.URIForFirstSelectedMessage;
I don't suppose it's worth adding something to gFolderDisplay to replace this?
Attachment #655933 - Flags: review?(neil) → review+
Changes since last version:
* Add selectedMessageUri to gFolderDisplay and utilised it;
* Removed GetNumSelectedMessages check in ToggleMessageTagKey function;
* Removed GetNumSelectedMessages check in MsgSaveAsTemplate function as only the first selected is passed through anyway;
* Reworked SelectedMessagesAreJunk function.
Attachment #655933 - Attachment is obsolete: true
Attachment #655998 - Flags: review?(neil)
Comment on attachment 655998 [details] [diff] [review]
Add to gFolderDisplay [Checked in: Comment 4]

Well, that's a slight change in behaviour for Save as Template, but then again it didn't do anything at all for a multiple selection, even though the option was enabled...
Attachment #655998 - Flags: review?(neil) → review+
Blocks: 786316
Comment on attachment 655998 [details] [diff] [review]
Add to gFolderDisplay [Checked in: Comment 4]
Attachment #655998 - Attachment description: Add to gFolderDisplay → Add to gFolderDisplay [Checked in: Comment 4]
Closed: 12 years ago
Flags: in-testsuite-
Flags: in-qa-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → seamonkey2.15
You need to log in before you can comment on or make changes to this bug.