1
1
import '../../config/polyfill'
2
2
3
3
import { setSourcegraphUrl } from '../../shared/util/context'
4
- import { featureFlags } from '../../shared/util/featureFlags'
5
4
import { injectCodeIntelligence } from '../code_intelligence'
6
5
import { getPhabricatorCSS , getSourcegraphURLFromConduit } from './backend'
7
- import { injectPhabricatorBlobAnnotators } from './inject_old'
8
- import { expanderListen , metaClickOverride , setupPageLoadListener } from './util'
6
+ import { metaClickOverride } from './util'
9
7
10
8
// NOTE: injectModules is idempotent, so safe to call multiple times on the same page.
11
9
async function injectModules ( ) : Promise < void > {
@@ -14,52 +12,43 @@ async function injectModules(): Promise<void> {
14
12
extensionMarker . style . display = 'none'
15
13
document . body . appendChild ( extensionMarker )
16
14
17
- if ( await featureFlags . isEnabled ( 'newInject' ) ) {
18
- await injectCodeIntelligence ( )
19
- } else {
20
- await injectPhabricatorBlobAnnotators ( )
21
- }
15
+ await injectCodeIntelligence ( )
22
16
}
23
17
24
18
export function init ( ) : void {
25
19
/**
26
20
* This is the main entry point for the phabricator in-page JavaScript plugin.
27
21
*/
28
22
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
+ }
39
31
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 ) )
63
52
} else {
64
53
// tslint:disable-next-line
65
54
console . log (
0 commit comments