pages/search: actions: pin or unpin tab

This commit is contained in:
He4eT 2024-01-21 21:56:29 +01:00
commit 60d28b9970
2 changed files with 10 additions and 2 deletions

View file

@ -18,9 +18,8 @@ export const actionboxHandlers = (commandQuery, store, flush) => {
/* */ /* */
'c': duplicateTab, 'c': duplicateTab,
's': discardTab, 's': discardTab,
'p': pinOrUnpinTab,
// 'e': Pop the tab into it's own window with minimal UI // '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) }[command] ?? noop(command))(store, label, flush)
} }
@ -78,3 +77,11 @@ function duplicateTab (store, label, flush) {
store.actions.createBackgroundTab(tab.url) store.actions.createBackgroundTab(tab.url)
} }
} }
function pinOrUnpinTab (store, label, flush) {
const tab = getTabByLabel(store, label)
if (tab) {
flush()
store.actions.updateTab(tab.id, {pinned: !tab.pinned})
}
}

View file

@ -25,6 +25,7 @@ export const init = ({
'favIconUrl', 'favIconUrl',
'id', 'id',
'label', 'label',
'pinned',
'title', 'title',
'url', 'url',
].reduce((acc, x) => (acc[x] = tab[x], acc), {}) ].reduce((acc, x) => (acc[x] = tab[x], acc), {})