Skip to content

Commit 587dd3f

Browse files
committed
fix(LocalTabs): Fix dummyTab workaround for tab group creation on firefox
Signed-off-by: Marcel Klehr <[email protected]>
1 parent 51ac221 commit 587dd3f

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/lib/LocalTabs.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -280,42 +280,42 @@ export default class LocalTabs implements OrderFolderResource<typeof ItemLocatio
280280
} else {
281281
// Otherwise, create a tab group
282282
try {
283-
// Create a dummy tab in the parent window to hold the group
284-
const dummyTab = await this.queue.add(() =>
285-
browser.tabs.create({
283+
const groupId = await this.queue.add(async() => {
284+
// Create a dummy tab in the parent window to hold the group
285+
const dummyTab = await browser.tabs.create({
286286
windowId: folder.parentId,
287287
url: 'about:blank',
288288
active: false
289289
})
290-
)
291290

292-
// Create a tab group with the dummy tab
293-
const groupId = await this.queue.add(() =>
294-
browser.tabs.group({
291+
// Create a tab group with the dummy tab
292+
const groupId = await browser.tabs.group({
295293
tabIds: [dummyTab.id],
296294
createProperties: {
297295
windowId: folder.parentId
298296
}
299297
})
300-
)
301298

302-
// Update the tab group title
303-
if (folder.title) {
304-
await this.queue.add(() =>
305-
browser.tabGroups.update(groupId, {
299+
// Update the tab group title
300+
if (folder.title) {
301+
await browser.tabGroups.update(groupId, {
306302
title: folder.title
307303
})
308-
)
309-
}
310-
311-
// Remove the dummy tab after a timeout
312-
setTimeout(async() => {
313-
try {
314-
await browser.tabs.remove(dummyTab.id)
315-
} catch (e) {
316-
Logger.log('Failed to remove dummy tab', e)
317304
}
318-
}, 2000)
305+
306+
await awaitTabsUpdated()
307+
308+
// Remove the dummy tab after a timeout
309+
setTimeout(async() => {
310+
try {
311+
await browser.tabs.remove(dummyTab.id)
312+
} catch (e) {
313+
Logger.log('Failed to remove dummy tab', e)
314+
}
315+
}, 2000)
316+
317+
return groupId
318+
})
319319

320320
await awaitTabsUpdated()
321321
return groupId

0 commit comments

Comments
 (0)