Skip to content

Refactor inject.tsx

Warren Gifford requested to merge inject-refactor into master

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 function determineCodeHost
  • Always call setSourcegraphUrl for all code hosts
  • Always add the extension marker
  • Do not make isPhabricator check depend on storageItems.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 in enterpriseUrls 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 from getPlatformContext() 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

Merge request reports

Loading