mirror of
https://github.com/He4eT/tabswitcher.git
synced 2026-05-05 01:17:23 +00:00
pages/search: improve usability
This commit is contained in:
parent
9c24d16071
commit
dbb7724253
3 changed files with 16 additions and 10 deletions
|
|
@ -10,19 +10,25 @@ export const actionboxHandlers = (commandQuery, store, flush) => {
|
|||
|
||||
({
|
||||
'?': openHelp,
|
||||
'x': closeCurrentTab,
|
||||
'q': closeCurrentTab,
|
||||
'r': reloadCurrentTab,
|
||||
/* */
|
||||
'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
|
||||
// 'e': Pop the tab into it's own window with minimal UI
|
||||
}[command] ?? noop(command))(store, label, flush)
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
function openHelp () {
|
||||
|
||||
const helpLink = 'https://github.com/He4eT/tabswitcher#Tabswitcher'
|
||||
location.href = helpLink
|
||||
}
|
||||
|
||||
function closeCurrentTab () {
|
||||
|
|
@ -44,7 +50,6 @@ function switchToTab (store, label) {
|
|||
const tab = getTabByLabel(store, label)
|
||||
if (tab) {
|
||||
store.actions.goToTab(tab.id)
|
||||
flush()
|
||||
closeCurrentTab()
|
||||
}
|
||||
}
|
||||
|
|
@ -52,18 +57,18 @@ function switchToTab (store, label) {
|
|||
function closeTab (store, label, flush) {
|
||||
const tab = getTabByLabel(store, label)
|
||||
if (tab) {
|
||||
store.actions.closeTab(tab.id)
|
||||
flush()
|
||||
store.actions.closeTab(tab.id)
|
||||
}
|
||||
}
|
||||
|
||||
function duplicateTab (store, label, flush) {
|
||||
const tab = getTabByLabel(store, label)
|
||||
if (tab) {
|
||||
flush()
|
||||
browser.tabs.create({
|
||||
active: false,
|
||||
url: tab.url,
|
||||
}).then(store.actions.updateState)
|
||||
flush()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,11 +80,9 @@ export const attachInputHandlers = (store) => {
|
|||
searchBox.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
let visibleTabs = store.getCurrentState().results
|
||||
if (visibleTabs.length === 1) {
|
||||
if (visibleTabs.length > 0) {
|
||||
const tabId = visibleTabs[0].obj.id
|
||||
switchToTab(tabId)
|
||||
} else {
|
||||
actionbox.focus()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue