Skip to content

Commit

Permalink
feat: Searching also in the account name
Browse files Browse the repository at this point in the history
  • Loading branch information
micz committed Feb 9, 2025
1 parent ea74239 commit 8b6cfd1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,8 @@
},
"partialMatchFullPath": {
"message": "Search for keywords within the entire folder path"
},
"searchAccountName": {
"message": "Search for keywords also within the account name"
}
}
1 change: 1 addition & 0 deletions src/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const DEFAULT_PREFERENCES = {
migratedShiftArrow: false,
recentStrategy: "accessed",
partialMatchFullPath: false,
searchAccountName: false,
};

export async function getValidatedFolders(rootNode, prefName) {
Expand Down
4 changes: 4 additions & 0 deletions src/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<input type="checkbox" id="partialMatchFullPath">
<label for="partialMatchFullPath" data-l10n-id="partialMatchFullPath"></label>
</div>
<div class="preference">
<input type="checkbox" id="searchAccountName">
<label for="searchAccountName" data-l10n-id="searchAccountName"></label>
</div>
<div class="preference" data-l10n-attr-title="useLegacyShortcutsTitle">
<input type="checkbox" id="useLegacyShortcuts">
<label for="useLegacyShortcuts" data-l10n-id="useLegacyShortcuts"></label>
Expand Down
3 changes: 2 additions & 1 deletion src/popup/baseItemList.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class BaseItemList extends HTMLElement {

ignoreFocus = false;
partialMatchFullPath = false;
searchAccountName = false;

static observedAttributes = ["placeholder"];

Expand Down Expand Up @@ -517,7 +518,7 @@ export default class BaseItemList extends HTMLElement {

if (this.partialMatchFullPath) {
for (let item of this.allItems) {
let pathString = item.fullSearchString.toLowerCase();
let pathString = (this.searchAccountName ? (item.account.name.toLowerCase() + "/") : "") + item.fullSearchString.toLowerCase();

if (!hasAccent) {
pathString = pathString.normalize("NFD").replace(DIACRITICS, "");
Expand Down
3 changes: 2 additions & 1 deletion src/popup/folderList.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ class TBFolderList extends BaseItemList {
return body.lastElementChild;
}

initItems(allItems, defaultItems, showFolderPath=false, excludeSet=null, partialMatchFullPath=false) {
initItems(allItems, defaultItems, showFolderPath=false, excludeSet=null, partialMatchFullPath=false, searchAccountName=false) {
this._allItems = allItems;
this._defaultItems = defaultItems;
this.#showFolderPath = showFolderPath;
this.#excludeSet = excludeSet || new Set();
this.partialMatchFullPath = partialMatchFullPath;
this.searchAccountName = searchAccountName;
this.repopulate();
}

Expand Down
4 changes: 2 additions & 2 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function load() {

let {
maxRecentFolders, showFolderPath, skipArchive, layout, defaultFolderSetting, migratedShiftArrow,
recentStrategy, partialMatchFullPath
recentStrategy, partialMatchFullPath, searchAccountName
} = await browser.storage.local.get(DEFAULT_PREFERENCES);

if (layout == "wide" || (layout == "auto" && window.outerWidth > 1400)) {
Expand Down Expand Up @@ -154,7 +154,7 @@ async function load() {
}

let folderList = document.getElementById("folder-list");
folderList.initItems(rootNode.folderNodes, defaultFolders, showFolderPath, excludeSet, partialMatchFullPath);
folderList.initItems(rootNode.folderNodes, defaultFolders, showFolderPath, excludeSet, partialMatchFullPath, searchAccountName);
folderList.ignoreFocus = true;
folderList.addEventListener("item-selected", async (event) => {
let { folder, altMode } = event.detail;
Expand Down

0 comments on commit 8b6cfd1

Please sign in to comment.