:tabclose now accepts win.tab format

This commit is contained in:
Oliver Blanthorn 2021-01-10 12:22:17 +01:00
parent 239566a2aa
commit 97719fb32f
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -2475,8 +2475,15 @@ export async function fullscreen() {
//#background
export async function tabclose(...indexes: string[]) {
let done
async function maybeWinTabToTabId(id: string) {
if (id.includes(".")) {
const [winid, tabindex_number] = await parseWinTabIndex(id)
return (await browser.tabs.query({ windowId: winid, index: tabindex_number }))[0].id
}
return idFromIndex(id)
}
if (indexes.length > 0) {
const ids = await Promise.all(indexes.map(index => idFromIndex(index)))
const ids = await Promise.all(indexes.map(index => maybeWinTabToTabId(index)))
done = browser.tabs.remove(ids)
} else {
// Close current tab