Skip to content

Commit

Permalink
Notify virtual "sticked" state via API if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 21, 2024
1 parent cc9a098 commit 8609c01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions webextensions/common/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ export default class Tab {
return this.states.has(Constants.kTAB_STATE_STICKY);
}

get sticked() {
return this.element?.parentNode?.classList.contains('sticky-tabs-container');
}

get isNewTabCommandTab() {
if (!this.tab ||
!configs.guessNewOrphanTabAsOpenedByNewTabCommand)
Expand Down Expand Up @@ -2051,6 +2055,8 @@ export default class Tab {
ancestorTabIds: this.tab.$TST.ancestorIds,
bundledTabId: this.tab.$TST.bundledTabId,
};
if (this.sticked)
exportedTab.states.push(Constants.kTAB_STATE_STICKED);
if (configs.cacheAPITreeItems && light)
this.$exportedForAPI = exportedTab;
}
Expand Down
3 changes: 3 additions & 0 deletions webextensions/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const kTAB_STATE_GROUP_TAB = 'group-tab';
export const kTAB_STATE_NEW_TAB_COMMAND_TAB = 'newtab-command-tab';
export const kTAB_STATE_OPENED_FOR_SAME_WEBSITE = 'opened-for-same-website';
export const kTAB_STATE_STICKY = 'sticky';
export const kTAB_STATE_STICKED = 'sticked'; // virtual state
export const kTAB_INTERNAL_STATES = new Set([ // TST specific states
'tab',
kTAB_STATE_LAST_ROW,
Expand All @@ -239,6 +240,7 @@ export const kTAB_INTERNAL_STATES = new Set([ // TST specific states
kTAB_STATE_FROM_FIREFOX_VIEW,
kTAB_STATE_OPENED_FOR_SAME_WEBSITE,
kTAB_STATE_STICKY,
kTAB_STATE_STICKED,
]);
export const kTAB_TEMPORARY_STATES = new Set([ // states not trigger updating of cache
kTAB_STATE_CREATING,
Expand Down Expand Up @@ -269,6 +271,7 @@ export const kTAB_SAFE_STATES = new Set([ // exportable via API
kTAB_STATE_FROM_FIREFOX_VIEW,
kTAB_STATE_OPENED_FOR_SAME_WEBSITE,
kTAB_STATE_STICKY,
kTAB_STATE_STICKED,
]);
export const kTAB_SAFE_STATES_ARRAY = Array.from(kTAB_SAFE_STATES);

Expand Down

0 comments on commit 8609c01

Please sign in to comment.