From f8ec211e19a78500a223c997ed5d7ec6ec89f628 Mon Sep 17 00:00:00 2001 From: He4eT Date: Sun, 21 Jan 2024 21:49:45 +0100 Subject: [PATCH] pages/search: actions: discardTab --- pages/search/modules/actionboxHandlers.js | 16 ++++++++++++---- pages/search/modules/store.js | 8 ++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pages/search/modules/actionboxHandlers.js b/pages/search/modules/actionboxHandlers.js index 25d78d7..bb174a4 100644 --- a/pages/search/modules/actionboxHandlers.js +++ b/pages/search/modules/actionboxHandlers.js @@ -15,12 +15,12 @@ export const actionboxHandlers = (commandQuery, store, flush) => { /* */ 'f': switchToTab, 'd': closeTab, + /* */ 'c': duplicateTab, - /* TODO */ - // 'p': Pin or unpin the tab - // 'm': Mute or unmute the tab - // 's': Put the tab to sleep + 's': discardTab, // 'e': Pop the tab into it's own window with minimal UI + // 'm': Mute or unmute the tab + // 'p': Pin or unpin the tab }[command] ?? noop(command))(store, label, flush) } @@ -63,6 +63,14 @@ function closeTab (store, label, flush) { } } +function discardTab (store, label, flush) { + const tab = getTabByLabel(store, label) + if (tab) { + flush() + store.actions.discardTab(tab.id) + } +} + function duplicateTab (store, label, flush) { const tab = getTabByLabel(store, label) if (tab) { diff --git a/pages/search/modules/store.js b/pages/search/modules/store.js index f1a2cce..a74d5bb 100644 --- a/pages/search/modules/store.js +++ b/pages/search/modules/store.js @@ -89,6 +89,14 @@ export const init = ({ url, }).then(updateState) }, + discardTab(id) { + browserTabs.discard(id) + .then(updateState) + }, + updateTab(id, options) { + browserTabs.update(id, options) + .then(updateState) + }, updateQuery(query) { state.query = query updateState()