Bug 966276 - pop3 account advanced deferring dialog broken - followup patch. r=squib SEA_2_26_1_RELBRANCH
authoralta88
Wed, 26 Feb 2014 17:20:52 -0700
branchSEA_2_26_1_RELBRANCH
changeset 31068 3c60f4ed95d0966657820f4bff8e7c6c351f90c9
parent 31067 2330f1f99c2af0517f0eb429a7b8f569df00d5ae
child 31069 fd910d1fd8f0a226948bb015d66069c45ca93cd9
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssquib
bugs966276
Bug 966276 - pop3 account advanced deferring dialog broken - followup patch. r=squib
mailnews/base/prefs/content/am-server-advanced.js
mailnews/base/prefs/content/am-server-advanced.xul
--- a/mailnews/base/prefs/content/am-server-advanced.js
+++ b/mailnews/base/prefs/content/am-server-advanced.js
@@ -69,16 +69,19 @@ function onLoad()
       // disabled by the picker with an appropriate message.
       folderPopup.selectFolder();
       if (gServerSettings.account.incomingServer.isDeferredTo) {
         // Some other account already defers to this account
         // therefore this one can't be deferred further.
         radioGroup.disabled = true;
       }
     }
+
+    let picker = document.getElementById("deferredServerFolderPicker");
+    picker.disabled = radioGroup.selectedIndex != 1;
   }
 
   var controls = getControls();
 
   for (var i = 0; i < controls.length; i++)
   {
     var slot = controls[i].id;
     if (slot in gServerSettings)
@@ -93,36 +96,40 @@ function onLoad()
 
 function onOk()
 {
   // Handle account deferral settings for POP3 accounts.
   if (gServerSettings.serverType == "pop3")
   {
     var radioGroup = document.getElementById("folderStorage");
     var gPrefsBundle = document.getElementById("bundle_prefs");
+    let picker = document.getElementById("deferredServerFolderPicker");
 
-    // if this account wasn't deferred, and is now...
+    // This account wasn't previously deferred, but is now deferred.
     if (radioGroup.value != "currentAccount" && !gFirstDeferredAccount.length)
     {
+      // If the user hasn't selected a folder, keep the default.
+      if (!picker.selectedItem)
+        return true;
+
       var confirmDeferAccount =
         gPrefsBundle.getString("confirmDeferAccountWarning");
 
       var confirmTitle = gPrefsBundle.getString("confirmDeferAccountTitle");
 
       if (!Services.prompt.confirm(window, confirmTitle, confirmDeferAccount))
         return false;
     }
     switch (radioGroup.value)
     {
       case "currentAccount":
         gServerSettings['deferredToAccount'] = "";
         break;
       case "otherAccount":
-        let server = document.getElementById("deferredServerFolderPicker")
-                             .selectedItem._folder.server;
+        let server = picker.selectedItem._folder.server;
         let account = MailServices.accounts.FindAccountForServer(server);
         gServerSettings['deferredToAccount'] = account.key;
         break;
     }
   }
 
   // Save the controls back to the "gServerSettings" array.
   var controls = getControls();
--- a/mailnews/base/prefs/content/am-server-advanced.xul
+++ b/mailnews/base/prefs/content/am-server-advanced.xul
@@ -116,18 +116,16 @@
                      label="&accountDirectory.label;"
                      accesskey="&accountDirectory.accesskey;"/>
             </row>
             <row>
               <radio id="deferToOtherAccount"
                      value="otherAccount"
                      label="&deferToServer.label;"
                      accesskey="&deferToServer.accesskey;">
-                <observes element="deferredServerFolderPicker"
-                          attribute="disabled"/>
               </radio>
               <menulist id="deferredServerFolderPicker"
                         class="folderMenuItem"
                         aria-labelledby="deferToServer">
                 <menupopup id="deferredServerPopup"
                            type="folder"
                            expandFolders="false"
                            mode="deferred"