From c36de380d07868ba09922ee59a4e0291c581a13d Mon Sep 17 00:00:00 2001 From: Bill13579 <35489013+Bill13579@users.noreply.github.com> Date: Sat, 21 Sep 2024 08:59:53 +0800 Subject: [PATCH] Fix 'a' deselect when all visible tabs are already selected for when filtering is active; add options for the what's new page --- dist/options/options.css | 14 ++++++++++++++ dist/options/options.html | 3 ++- ext-info.js | 3 ++- src/background/background.js | 14 ++++++++++---- src/options/exports.js | 1 + src/options/options.js | 23 +++++++++++++++++++++++ src/popup/popup.js | 5 ++++- 7 files changed, 56 insertions(+), 7 deletions(-) diff --git a/dist/options/options.css b/dist/options/options.css index 21e4f48..2de12a7 100644 --- a/dist/options/options.css +++ b/dist/options/options.css @@ -102,4 +102,18 @@ body { .beta { color: #ff0000; font-weight: bold; +} + +/* Option specific declarations */ +#option-show-whats-new-on[data-state="update"]::after { + content: "Showing on updates"; +} +#option-show-whats-new-on[data-state="major-update"]::after { + content: "Showing on major updates"; +} +#option-show-whats-new-on[data-state="never"]::after { + content: "Never showing"; +} +#option-show-whats-new-on { + font-size: small; } \ No newline at end of file diff --git a/dist/options/options.html b/dist/options/options.html index a51781e..1a6f88a 100644 --- a/dist/options/options.html +++ b/dist/options/options.html @@ -110,7 +110,8 @@ [What's - new?]
+ new?] +
[Bug Report with Github] [Bug Report diff --git a/ext-info.js b/ext-info.js index 35455e3..3faabe8 100644 --- a/ext-info.js +++ b/ext-info.js @@ -1,3 +1,4 @@ module.exports = { - EXT_VERSION: "3.2" + EXT_VERSION: "3.2", + EXT_IS_MAJOR_RELEASE: true }; diff --git a/src/background/background.js b/src/background/background.js index 172386f..05fa45e 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -5,6 +5,8 @@ import { TSession } from "../tapi/tsession"; import { TTabActions } from "../tapi/taction"; import LZString from "lz-string"; import { TargetBrowser } from "../polyfill"; +import { resolveDefault } from "../options/exports"; +import { EXT_IS_MAJOR_RELEASE } from "../../ext-info"; // import { TSession } from "tapi/tsession"; @@ -15,10 +17,14 @@ import { TargetBrowser } from "../polyfill"; browser.runtime.onInstalled.addListener(({ reason }) => { if (reason !== "browser_update" && reason !== "chrome_update" && reason !== "shared_module_update") { - browser.tabs.create({ - active: true, - url: "https://github.com/Bill13579/tabby/wiki/3.2-The-Uwa!!-So-QoL%E2%99%AB-Update" - }); + $local$.fulfillOnce("option:show-whats-new-on", (showWhatsNewOn) => { + if (showWhatsNewOn === "update" || (EXT_IS_MAJOR_RELEASE && showWhatsNewOn === "major-update")) { + browser.tabs.create({ + active: true, + url: "https://github.com/Bill13579/tabby/wiki/3.2-The-Uwa!!-So-QoL%E2%99%AB-Update" + }); + } + }, resolveDefault("option:show-whats-new-on")); } }); diff --git a/src/options/exports.js b/src/options/exports.js index 7ee5066..029f506 100644 --- a/src/options/exports.js +++ b/src/options/exports.js @@ -10,6 +10,7 @@ let defaults = { "option:popup-custom-theme": "", "option:popup-theme": "classic", "option:dont-clear-search": true, + "option:show-whats-new-on": "major-update", "option:separate-save": false }; export function resolveDefault(optionID) { diff --git a/src/options/options.js b/src/options/options.js index 21f9bde..140c76c 100644 --- a/src/options/options.js +++ b/src/options/options.js @@ -179,6 +179,29 @@ $local$.fulfill("option:dont-clear-search", (dontClearSearch) => { dontClearSearchSwitch.checked = dontClearSearch; }, resolveDefault("option:dont-clear-search")); +//option:show-whats-new-on +$local$.fulfill("option:show-whats-new-on", (showWhatsNewOn) => { + // Get elements + let showWhatsNewOnLabel = document.querySelector("#option-show-whats-new-on"); + + // Set on click listener + showWhatsNewOnLabel.onclick = (evt) => { + $local$.modify("option:show-whats-new-on", (current) => { + switch (current) { + case "update": + return "major-update"; + case "major-update": + return "never"; + case "never": + return "update"; + } + }, true); + }; + + // Set current values + showWhatsNewOnLabel.setAttribute("data-state", showWhatsNewOn); +}, resolveDefault("option:show-whats-new-on")); + //option:separate-save $local$.fulfill("option:separate-save", (separateSave) => { // Get elements diff --git a/src/popup/popup.js b/src/popup/popup.js index d872e81..be25918 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -1981,8 +1981,11 @@ class TUITabsList extends TUIListDataInterpret { } } let allChildren = tabsList.children(tabsList.root, true); + let visibleChildrenCount = allChildren.reduce((accum, child) => accum + ( + TUIList.isElementVisible(child) ? 1 : 0 + ), 0); for (let child of allChildren) { - if (allChildren.length > count && TUIList.isElementVisible(child)) { + if (visibleChildrenCount > count && TUIList.isElementVisible(child)) { processSelectCB(child, evt, "selecting", true); } else { processSelectCB(child, evt, "unselecting", true);