Skip to content

Commit

Permalink
Improve startup behavior
Browse files Browse the repository at this point in the history
- Ensures that the selected folder is on the screen after refreshing the pane.
- Select startup folder after that.
- Display the URI as well as the pretty name in the startup folder picker.
- Revision 2.2.3
  • Loading branch information
itagagaki committed Oct 29, 2022
1 parent 04cd543 commit 56d2776
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
33 changes: 22 additions & 11 deletions content/folderPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@
};
myPrefObserver.register();

/* Refresh pane */
function refreshPane(win) {
try { win.gFolderTreeView._rebuild(); }
catch (e) { setTimeout(refreshPane, 5, win); }
}
for (let win of Services.wm.getEnumerator("mail:3pane")) {
refreshPane(win);
}

/* Ensures that the selected folder is on the screen. */
{
const selected = gFolderTreeView.getSelectedFolders()[0];
if (selected) {
gFolderTreeView._treeElement.ensureRowIsVisible(gFolderTreeView.getIndexOfFolder(selected));
}
}

/* For default startup folder */
const startup_folder = tbsf_prefs.getStringPref("startup_folder");
Expand All @@ -182,7 +198,7 @@
if (firstRun && inRestoreTab) {
const folder = MailUtils.getExistingFolder(startup_folder);
if (folder)
oldSelectFolder.call(this, folder, true);
oldSelectFolder.call(this, folder);
else
oldSelectFolder.call(this, x, y);
firstRun = false;
Expand All @@ -197,18 +213,13 @@
*/
const folder = MailUtils.getExistingFolder(startup_folder);
if (folder) {
gFolderTreeView.selectFolder(folder, true);
if (!gFolderTreeView.selectFolder(folder)) {
tblog.debug("selectFolder failed");
}
} else {
tblog.debug(startup_folder+" not found");
}
}
}

/* Refresh pane */
function refreshPane(win) {
try { win.gFolderTreeView._rebuild(); }
catch (e) { setTimeout(refreshPane, 5, win); }
}
for (let win of Services.wm.getEnumerator("mail:3pane")) {
refreshPane(win);
}

})()
5 changes: 3 additions & 2 deletions content/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ function on_pick_folder(aEvent) {
let folder = aEvent.target._folder;
let picker = document.getElementById("startupFolder");
picker.folder = folder;
picker.setAttribute("label", folder.prettyName);
picker.setAttribute("label", folder.prettyName+' ('+folder.URI+')');
tbsf_prefs.setStringPref("startup_folder", folder.URI);
}

Expand All @@ -793,7 +793,7 @@ function extra_on_load() {
folder = MailUtils.getExistingFolder(startup_folder);
if (folder) {
picker.folder = folder;
picker.setAttribute("label", folder.prettyName);
picker.setAttribute("label", folder.prettyName+' ('+folder.URI+')');
} else {
let menu = document.getElementById("startup_folder_method");
menu.value = "0";
Expand All @@ -816,4 +816,5 @@ function on_startup_folder_method_changed() {
tbsf_prefs.setStringPref("startup_folder", "");
}
document.getElementById("startup_folder_notice").style.display = notice ? "" : "none";

}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Manually sort folders",
"description": "An extension that allows you to change the way Thunderbird sorts folders in the folder pane.",
"version": "2.2.2",
"version": "2.2.3",
"author": "Jonathan Protzenko and Itagaki Fumihiko",
"homepage_url": "https://github.com/protz/Manually-Sort-Folders/wiki",
"applications": {
Expand Down

0 comments on commit 56d2776

Please sign in to comment.