Skip to content

Commit

Permalink
feat: Tabs: 'sorting' flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnuqw committed Mar 3, 2024
1 parent 5f6f329 commit 6d94676
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/services/tabs.fg.handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function releaseReopenedTabsBuffer(): void {

function onTabCreated(nativeTab: NativeTab, attached?: boolean): void {
if (nativeTab.windowId !== Windows.id) return
if (Tabs.list.length === 0) {
if (Tabs.list.length === 0 || Tabs.sorting) {
Tabs.deferredEventHandling.push(() => onTabCreated(nativeTab))
return
}
Expand Down Expand Up @@ -460,7 +460,7 @@ function onTabCreated(nativeTab: NativeTab, attached?: boolean): void {
*/
function onTabUpdated(tabId: ID, change: browser.tabs.ChangeInfo, nativeTab: NativeTab): void {
if (nativeTab.windowId !== Windows.id) return
if (Tabs.list.length === 0 || waitForOtherReopenedTabsBuffer) {
if (Tabs.list.length === 0 || waitForOtherReopenedTabsBuffer || Tabs.sorting) {
Tabs.deferredEventHandling.push(() => onTabUpdated(tabId, change, nativeTab))
return
}
Expand Down Expand Up @@ -823,7 +823,7 @@ function rememberChildTabs(childId: ID, parentId: ID): void {
*/
function onTabRemoved(tabId: ID, info: browser.tabs.RemoveInfo, detached?: boolean): void {
if (info.windowId !== Windows.id) return
if (Tabs.list.length === 0 || waitForOtherReopenedTabsBuffer) {
if (Tabs.list.length === 0 || waitForOtherReopenedTabsBuffer || Tabs.sorting) {
Tabs.deferredEventHandling.push(() => onTabRemoved(tabId, info, detached))
return
}
Expand Down Expand Up @@ -1245,7 +1245,7 @@ function onTabMoved(id: ID, info: browser.tabs.MoveInfo): void {
*/
function onTabDetached(id: ID, info: browser.tabs.DetachInfo): void {
if (info.oldWindowId !== Windows.id) return
if (Tabs.list.length === 0) {
if (Tabs.list.length === 0 || Tabs.sorting) {
Tabs.deferredEventHandling.push(() => onTabDetached(id, info))
return
}
Expand Down Expand Up @@ -1276,7 +1276,7 @@ function onTabDetached(id: ID, info: browser.tabs.DetachInfo): void {
const deferredActivationHandling = { id: NOID, cb: null as (() => void) | null }
async function onTabAttached(id: ID, info: browser.tabs.AttachInfo): Promise<void> {
if (info.newWindowId !== Windows.id) return
if (Tabs.list.length === 0) {
if (Tabs.list.length === 0 || Tabs.sorting) {
Tabs.deferredEventHandling.push(() => onTabAttached(id, info))
return
}
Expand Down
1 change: 1 addition & 0 deletions src/services/tabs.fg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const Tabs = {
activeId: NOID,
blockedScrollPosition: false,
activateSelectedOnMouseLeave: false,
sorting: false,

...TabsActions,
...TabsHandlers,
Expand Down

0 comments on commit 6d94676

Please sign in to comment.