Skip to content

Commit

Permalink
Add new notification type API try-scroll-to-activated-tab to block au…
Browse files Browse the repository at this point in the history
…to-scrolling to the activated tab
  • Loading branch information
piroor committed Aug 21, 2024
1 parent 0840d13 commit cc9a098
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions webextensions/common/tst-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const kNOTIFY_TRY_COLLAPSE_TREE_FROM_COLLAPSE_COMMAND = 'try-collapse-tre
export const kNOTIFY_TRY_COLLAPSE_TREE_FROM_COLLAPSE_ALL_COMMAND = 'try-collapse-tree-from-collapse-all-command';
export const kNOTIFY_TRY_FIXUP_TREE_ON_TAB_MOVED = 'try-fixup-tree-on-tab-moved';
export const kNOTIFY_TRY_HANDLE_NEWTAB = 'try-handle-newtab';
export const kNOTIFY_TRY_SCROLL_TO_ACTIVATED_TAB = 'try-scroll-to-activated-tab';
export const kGET_TREE = 'get-tree';
export const kGET_LIGHT_TREE = 'get-light-tree';
export const kATTACH = 'attach';
Expand Down
15 changes: 14 additions & 1 deletion webextensions/sidebar/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ async function onBackgroundMessage(message) {
}
}; break;

case Constants.kCOMMAND_NOTIFY_TAB_ACTIVATED:
case Constants.kCOMMAND_NOTIFY_TAB_ACTIVATED: {
if (tryLockScrollToSuccessor.tabId == message.tabId) {
log('tryLockScrollToSuccessor: wait until unlocked for ', message.tabId);
mLastToBeActivatedTabId = message.tabId;
Expand All @@ -1263,6 +1263,19 @@ async function onBackgroundMessage(message) {
}
unlockScrollToSuccessor(false);
mLastToBeActivatedTabId = null;
await Tab.waitUntilTracked(message.tabId);
const tab = Tab.get(message.tabId);
if (!tab)
break;
const allowed = await TSTAPI.tryOperationAllowed(
TSTAPI.kNOTIFY_TRY_SCROLL_TO_ACTIVATED_TAB,
{ tab },
{ tabProperties: ['tab'] }
);
if (allowed)
reserveToScrollToTab(tab);
}; break;

case Constants.kCOMMAND_NOTIFY_TAB_UNPINNED:
await Tab.waitUntilTracked(message.tabId);
reserveToScrollToTab(Tab.get(message.tabId));
Expand Down

0 comments on commit cc9a098

Please sign in to comment.