diff --git a/dist/options/options.html b/dist/options/options.html index 2504286..02cb9a7 100644 --- a/dist/options/options.html +++ b/dist/options/options.html @@ -45,6 +45,10 @@
+
+ +
+
diff --git a/package-lock.json b/package-lock.json index 5562a75..6834c33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tabby", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/options/options.js b/src/options/options.js index 74e7c9f..2155c2d 100644 --- a/src/options/options.js +++ b/src/options/options.js @@ -56,6 +56,7 @@ function readOptions() { setSubOptionState(options.popup.showDetails, document.getElementById("option-preview").parentElement); setSwitchState(document.getElementById("option-hide-after-tab-switch"), options.popup.hideAfterTabSelection); setSwitchState(document.getElementById("option-search-urls"), options.popup.searchInURLs); + setSwitchState(document.getElementById("option-show-most-recent-top"), options.popup.sortByLastAccessed); }); } @@ -118,6 +119,13 @@ function addEventListeners() { browser.storage.local.set(data); }); }); + + document.getElementById("option-show-most-recent-top").addEventListener("input", e => { + browser.storage.local.get(["options"]).then(data => { + data.options.popup.sortByLastAccessed = getSwitchState(e.target); + browser.storage.local.set(data); + }); + }); } function main() { diff --git a/src/popup/globals.js b/src/popup/globals.js index 6d74973..74af7e4 100644 --- a/src/popup/globals.js +++ b/src/popup/globals.js @@ -4,6 +4,7 @@ const globals = { tabsList: undefined, isSelecting: false, hideAfterTabSelection: undefined, - searchInURLs: undefined + searchInURLs: undefined, + sortByLastAccessed: undefined }; export default globals; diff --git a/src/popup/popup.js b/src/popup/popup.js index 2fad2d2..424ce85 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -45,6 +45,8 @@ async function fulfillOptions() { G.hideAfterTabSelection = Options.stbool(popupOptions.hideAfterTabSelection); // popup.searchInURLs G.searchInURLs = Options.stbool(popupOptions.searchInURLs); + // popup.sortByLastAccessed + G.sortByLastAccessed = Options.stbool(popupOptions.sortByLastAccessed); } async function main() { @@ -151,4 +153,4 @@ function generalSetup() { // Tell background script that everything is loaded now sendRuntimeMessage("INIT__POPUP_LOADED", {}); -} \ No newline at end of file +} diff --git a/src/popup/wtinit.js b/src/popup/wtinit.js index 3e76e48..4880ea0 100644 --- a/src/popup/wtinit.js +++ b/src/popup/wtinit.js @@ -114,6 +114,9 @@ export async function updateTabs(windows) { let windowTabsListFragment = document.createDocumentFragment(); // Loop through tabs + if(G.sortByLastAccessed){ + w.tabs.sort((a,b)=>a.lastAccessed < b.lastAccessed) + } for (let i = 0; i < w.tabs.length; i++) { let tab = w.tabs[i]; // Check tab id