Refactor inject.tsx
Created by: felixfbecker
Refactors inject.tsx.
- Use async/await instead of callbacks and events
- Remove the
sourcegraph:storage-init
event, it used to be fired in Safari but that code doesn't exist anymore. - Remove all the
is*
checks in favor of a functiondetermineCodeHost
- Always call
setSourcegraphUrl
for all code hosts - Always add the extension marker
-
⚠ ️ Do not makeisPhabricator
check depend onstorageItems.enterpriseUrls
. I can't imagine how Phabricator could not have the HTML element that is checked for, and if it doesn't, it seems wrong to report any URL that is inenterpriseUrls
as Phabricator (@KattMingMing indicated that it can contain GHE URLs) - This allows making
CodeHost.check()
sync again - Do not assign
window.SOURCEGRAPH_PHABRICATOR_EXTENSION
in the bext inject.tsx, instead in the Phabricator integration entry point. The reference to it fromgetPlatformContext()
indicate that it is intended to mean that (this is only used for titles and user agent strings though, nothing critical).
Test Plan
Code Hosts
-
GitHub -
GitHub Enterprise -
Phabricator -
Phabricator integration -
Bitbucket -
Gitlab
Browsers
-
Chrome -
Firefox