pages/search: actions: extract tab to popup

This commit is contained in:
He4eT 2024-01-21 22:08:45 +01:00
commit 194c1fa2bc
3 changed files with 18 additions and 1 deletions

View file

@ -19,7 +19,7 @@ export const actionboxHandlers = (commandQuery, store, flush) => {
'c': duplicateTab, 'c': duplicateTab,
's': discardTab, 's': discardTab,
'p': pinOrUnpinTab, 'p': pinOrUnpinTab,
// 'e': Pop the tab into it's own window with minimal UI 'e': moveTabToPopup,
}[command] ?? noop(command))(store, label, flush) }[command] ?? noop(command))(store, label, flush)
} }
@ -78,6 +78,15 @@ function duplicateTab (store, label, flush) {
} }
} }
function moveTabToPopup (store, label, flush) {
const tab = getTabByLabel(store, label)
if (tab) {
flush()
store.actions.moveTabToPopup(tab.id)
store.actions.closeCurrentTab()
}
}
function pinOrUnpinTab (store, label, flush) { function pinOrUnpinTab (store, label, flush) {
const tab = getTabByLabel(store, label) const tab = getTabByLabel(store, label)
if (tab) { if (tab) {

View file

@ -3,6 +3,7 @@ const fuzzysort = window.fuzzysort
export const init = ({ export const init = ({
tabs: browserTabs, tabs: browserTabs,
windows: browserWindows,
onStateUpdate, onStateUpdate,
closeCurrentTab, closeCurrentTab,
}) => { }) => {
@ -94,6 +95,12 @@ export const init = ({
browserTabs.discard(id) browserTabs.discard(id)
.then(updateState) .then(updateState)
}, },
moveTabToPopup(id) {
browserWindows.create({
tabId: id,
type: 'popup',
}).then(updateState)
},
updateTab(id, options) { updateTab(id, options) {
browserTabs.update(id, options) browserTabs.update(id, options)
.then(updateState) .then(updateState)

View file

@ -4,6 +4,7 @@ import * as inputHandlers from './modules/inputHandlers.js'
const store = Store.init({ const store = Store.init({
tabs: browser.tabs, tabs: browser.tabs,
windows: browser.windows,
onStateUpdate: dom.updateSearchResults, onStateUpdate: dom.updateSearchResults,
closeCurrentTab: () => window.close(), closeCurrentTab: () => window.close(),
}) })