-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#7675: Reuse SimpleEventTarget
wherever possible
#7765
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4773f22
Use `SimpleEventTarget` wherever possible
fregante f26af55
menuItemExtension: Use `EventTarget` for `cancelDependencyObservers`
fregante 4454d31
menuItemExtension: Also disconnect on abort
fregante 050bc2a
`contentScript/lifecycle`: Use `RepeatableAbortController`
fregante 2c57126
`quickBarRegistry`
fregante 2b4c652
useTreeRow
fregante 7a25d43
Merge remote-tracking branch 'origin/main' into F/dev/listeners
fregante 9bbc210
`quickBarRegistry` / 2
fregante 22c34af
useTreeRow /2
fregante ba80560
HMR tweaks
fregante 49b3906
`menuItemExtension` - Clarify EventTarget usage and wrap it in methods
fregante 1849fee
Merge remote-tracking branch 'origin/main' into F/dev/listeners
fregante 564d3c8
Lint
fregante 6d52779
s/databaseChangeListeners/packageRegistryChange/
fregante 05ed40c
MemoryRegistry: s/onCacheChanged/onChange/
fregante 528c288
Discard changes to src/starterBricks/menuItemExtension.ts
fregante ea26043
Merge branch 'main' into F/dev/listeners
fregante File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ import { | |
import { $safeFind } from "@/utils/domUtils"; | ||
import { onContextInvalidated } from "webext-events"; | ||
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu"; | ||
import { RepeatableAbortController } from "abort-utils"; | ||
|
||
/** | ||
* True if handling the initial page load. | ||
|
@@ -92,10 +93,9 @@ const _activeExtensionPoints = new Set<StarterBrick>(); | |
let lastUrl: string | undefined; | ||
|
||
/** | ||
* Abort controllers for navigation events for Single Page Applications (SPAs). | ||
* Abort controller for navigation events for Single Page Applications (SPAs). | ||
*/ | ||
// eslint-disable-next-line local-rules/persistBackgroundData -- Functions | ||
const _navigationListeners = new Set<() => void>(); | ||
const navigationListeners = new RepeatableAbortController(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also here |
||
|
||
const WAIT_LOADED_INTERVAL_MS = 25; | ||
|
||
|
@@ -324,23 +324,10 @@ export function clearEditorExtension( | |
} | ||
|
||
/** | ||
* Return an AbortSignal that's aborted when the user navigates. | ||
*/ | ||
function createNavigationAbortSignal(): AbortSignal { | ||
const controller = new AbortController(); | ||
_navigationListeners.add(controller.abort.bind(controller)); | ||
return controller.signal; | ||
} | ||
|
||
/** | ||
* Notifies all navigation listeners that the user has navigated in a way that changed the URL. | ||
* Notifies all the listeners that the user has navigated in a way that changed the URL. | ||
*/ | ||
function notifyNavigationListeners(): void { | ||
for (const listener of _navigationListeners) { | ||
listener(); | ||
} | ||
|
||
_navigationListeners.clear(); | ||
navigationListeners.abortAndReset(); | ||
} | ||
|
||
/** | ||
|
@@ -372,7 +359,7 @@ export async function runEditorExtension( | |
// The Page Editor is the only caller for runDynamic | ||
reason: RunReason.PAGE_EDITOR, | ||
extensionIds: [extensionId], | ||
abortSignal: createNavigationAbortSignal(), | ||
abortSignal: navigationListeners.signal, | ||
}); | ||
|
||
checkLifecycleInvariants(); | ||
|
@@ -587,14 +574,12 @@ export async function handleNavigate({ | |
updateNavigationId(); | ||
notifyNavigationListeners(); | ||
|
||
const abortSignal = createNavigationAbortSignal(); | ||
|
||
const extensionPoints = await loadPersistedExtensionsOnce(); | ||
if (extensionPoints.length > 0) { | ||
// Wait for document to load, to ensure any selector-based availability rules are ready to be applied. | ||
await logPromiseDuration( | ||
"handleNavigate:waitDocumentLoad", | ||
waitDocumentLoad(abortSignal), | ||
waitDocumentLoad(navigationListeners.signal), | ||
); | ||
|
||
// Safe to use Promise.all because the inner method can't throw | ||
|
@@ -606,7 +591,7 @@ export async function handleNavigate({ | |
// extension point that runs on the contact information modal on LinkedIn | ||
const runPromise = runExtensionPoint(extensionPoint, { | ||
reason: runReason, | ||
abortSignal, | ||
abortSignal: navigationListeners.signal, | ||
}).catch((error) => { | ||
console.error("Error installing/running: %s", extensionPoint.id, { | ||
error, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested. Drops all the mouseenter/mouseover listeners from
useTreeRow.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, the up/down keys don't work :(