11import '../../config/polyfill'
22
33import { setSourcegraphUrl } from '../../shared/util/context'
4- import { featureFlags } from '../../shared/util/featureFlags'
54import { injectCodeIntelligence } from '../code_intelligence'
65import { getPhabricatorCSS , getSourcegraphURLFromConduit } from './backend'
7- import { injectPhabricatorBlobAnnotators } from './inject_old'
8- import { expanderListen , metaClickOverride , setupPageLoadListener } from './util'
6+ import { metaClickOverride } from './util'
97
108// NOTE: injectModules is idempotent, so safe to call multiple times on the same page.
119async function injectModules ( ) : Promise < void > {
@@ -14,52 +12,43 @@ async function injectModules(): Promise<void> {
1412 extensionMarker . style . display = 'none'
1513 document . body . appendChild ( extensionMarker )
1614
17- if ( await featureFlags . isEnabled ( 'newInject' ) ) {
18- await injectCodeIntelligence ( )
19- } else {
20- await injectPhabricatorBlobAnnotators ( )
21- }
15+ await injectCodeIntelligence ( )
2216}
2317
2418export function init ( ) : void {
2519 /**
2620 * This is the main entry point for the phabricator in-page JavaScript plugin.
2721 */
2822 if ( window . localStorage && window . localStorage . getItem ( 'SOURCEGRAPH_DISABLED' ) !== 'true' ) {
29- document . addEventListener ( 'phabPageLoaded' , ( ) => {
30- // Backwards compat: Support Legacy Phabricator extension. Check that the Phabricator integration
31- // passed the bundle url. Legacy Phabricator extensions inject CSS via the loader.js script
32- // so we do not need to do this here.
33- if ( ! window . SOURCEGRAPH_BUNDLE_URL && ! window . localStorage . getItem ( 'SOURCEGRAPH_BUNDLE_URL' ) ) {
34- injectModules ( ) . catch ( err => console . error ( 'Unable to inject modules' , err ) )
35- metaClickOverride ( )
36- expanderListen ( )
37- return
38- }
23+ // Backwards compat: Support Legacy Phabricator extension. Check that the Phabricator integration
24+ // passed the bundle url. Legacy Phabricator extensions inject CSS via the loader.js script
25+ // so we do not need to do this here.
26+ if ( ! window . SOURCEGRAPH_BUNDLE_URL && ! window . localStorage . getItem ( 'SOURCEGRAPH_BUNDLE_URL' ) ) {
27+ injectModules ( ) . catch ( err => console . error ( 'Unable to inject modules' , err ) )
28+ metaClickOverride ( )
29+ return
30+ }
3931
40- getSourcegraphURLFromConduit ( )
41- . then ( sourcegraphUrl => {
42- getPhabricatorCSS ( )
43- . then ( css => {
44- const style = document . createElement ( 'style' ) as HTMLStyleElement
45- style . setAttribute ( 'type' , 'text/css' )
46- style . id = 'sourcegraph-styles'
47- style . textContent = css
48- document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( style )
49- window . localStorage . setItem ( 'SOURCEGRAPH_URL' , sourcegraphUrl )
50- window . SOURCEGRAPH_URL = sourcegraphUrl
51- setSourcegraphUrl ( sourcegraphUrl )
52- expanderListen ( )
53- metaClickOverride ( )
54- injectModules ( ) . catch ( err => console . error ( 'Unable to inject modules' , err ) )
55- } )
56- . catch ( e => {
57- console . error ( e )
58- } )
59- } )
60- . catch ( e => console . error ( e ) )
61- } )
62- setupPageLoadListener ( )
32+ getSourcegraphURLFromConduit ( )
33+ . then ( sourcegraphUrl => {
34+ getPhabricatorCSS ( )
35+ . then ( css => {
36+ const style = document . createElement ( 'style' ) as HTMLStyleElement
37+ style . setAttribute ( 'type' , 'text/css' )
38+ style . id = 'sourcegraph-styles'
39+ style . textContent = css
40+ document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( style )
41+ window . localStorage . setItem ( 'SOURCEGRAPH_URL' , sourcegraphUrl )
42+ window . SOURCEGRAPH_URL = sourcegraphUrl
43+ setSourcegraphUrl ( sourcegraphUrl )
44+ metaClickOverride ( )
45+ injectModules ( ) . catch ( err => console . error ( 'Unable to inject modules' , err ) )
46+ } )
47+ . catch ( e => {
48+ console . error ( e )
49+ } )
50+ } )
51+ . catch ( e => console . error ( e ) )
6352 } else {
6453 // tslint:disable-next-line
6554 console . log (
0 commit comments