Skip to content

Commit

Permalink
Add "exclude discarded tabs" option for [Popup] All Tabs command (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbendebiene committed Jan 2, 2024
1 parent d263398 commit f177d85
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,8 @@
"description": "Determines if the tabs should be cycled through in a loop."
},
"commandSettingDescriptionExcludeDiscarded": {
"message": "Determines if tabs that are not loaded should be skipped.",
"description": "Determines if tabs that are not loaded should be skipped."
"message": "Determines whether tabs that are not loaded should be ignored.",
"description": "Determines whether tabs that are not loaded should be ignored."
},
"commandSettingDescriptionOpenEmptyTab": {
"message": "Determines if an empty tab should be opened if no URL or link was selected.",
Expand Down
9 changes: 7 additions & 2 deletions src/core/commands.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1854,10 +1854,15 @@ export async function OpenAddonSettings (sender, data) {


export async function PopupAllTabs (sender, data) {
const tabs = await browser.tabs.query({
const queryInfo = {
windowId: sender.tab.windowId,
hidden: false
});
};

if (this.getSetting("excludeDiscarded")) queryInfo.discarded = false;

const tabs = await browser.tabs.query(queryInfo);

// sort tabs if defined
switch (this.getSetting("order")) {
case "lastAccessedAsc":
Expand Down
3 changes: 2 additions & 1 deletion src/resources/json/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@
{
"command": "PopupAllTabs",
"settings": {
"order": "none"
"order": "none",
"excludeDiscarded": false
},
"permissions": ["tabs"],
"group": "popup"
Expand Down
12 changes: 6 additions & 6 deletions src/views/options/fragments/command-setting-templates.inc
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@
<p data-i18n="commandSettingDescriptionTabCycling" class="cb-setting-description"></p>
</template>

<template data-commands="FocusRightTab FocusLeftTab">
<span data-i18n="commandSettingLabelExcludeDiscarded" class="cb-setting-name"></span>
<input name="excludeDiscarded" class="toggle-button" type="checkbox">
<p data-i18n="commandSettingDescriptionExcludeDiscarded" class="cb-setting-description"></p>
</template>

<template data-commands="OpenLinkInNewTab">
<span data-i18n="commandSettingLabelOpenEmptyTab" class="cb-setting-name"></span>
<input name="emptyTab" class="toggle-button" type="checkbox">
Expand Down Expand Up @@ -168,6 +162,12 @@
</div>
</template>

<template data-commands="FocusRightTab FocusLeftTab PopupAllTabs">
<span data-i18n="commandSettingLabelExcludeDiscarded" class="cb-setting-name"></span>
<input name="excludeDiscarded" class="toggle-button" type="checkbox">
<p data-i18n="commandSettingDescriptionExcludeDiscarded" class="cb-setting-description"></p>
</template>

<template data-commands="ExecuteUserScript">
<span data-i18n="commandSettingLabelUserScriptWarning" class="cb-setting-name warning-text"></span>
<p class="cb-setting-description warning-text">
Expand Down

0 comments on commit f177d85

Please sign in to comment.