@@ -22,57 +22,18 @@ export default class Registry {
22
22
data : Plugin ,
23
23
callback : ( instance : DefaultIssuePlugin | DefaultPlugin | SessionStackPlugin ) => void
24
24
) {
25
- let remainingAssets = data . assets . length ;
26
25
// TODO(dcramer): we should probably register all valid plugins
27
- const finishLoad = ( ) => {
28
- if ( ! defined ( this . plugins [ data . id ] ) ) {
29
- if ( data . type === 'issue-tracking' ) {
30
- this . plugins [ data . id ] = DefaultIssuePlugin ;
31
- } else {
32
- this . plugins [ data . id ] = DefaultPlugin ;
33
- }
34
- }
35
- console . info (
36
- '[plugins] Loaded ' + data . id + ' as {' + this . plugins [ data . id ] . name + '}'
37
- ) ;
38
- callback ( this . get ( data ) ) ;
39
- } ;
40
-
41
- if ( remainingAssets === 0 ) {
42
- finishLoad ( ) ;
43
- return ;
44
- }
45
-
46
- const onAssetLoaded = function ( ) {
47
- remainingAssets -- ;
48
- if ( remainingAssets === 0 ) {
49
- finishLoad ( ) ;
50
- }
51
- } ;
52
-
53
- const onAssetFailed = function ( asset : { url : string } ) {
54
- remainingAssets -- ;
55
- console . error ( '[plugins] Failed to load asset ' + asset . url ) ;
56
- if ( remainingAssets === 0 ) {
57
- finishLoad ( ) ;
58
- }
59
- } ;
60
-
61
- // TODO(dcramer): what do we do on failed asset loading?
62
- data . assets . forEach ( asset => {
63
- if ( ! defined ( this . assetCache [ asset . url ] ) ) {
64
- console . info ( '[plugins] Loading asset for ' + data . id + ': ' + asset . url ) ;
65
- const s = document . createElement ( 'script' ) ;
66
- s . src = asset . url ;
67
- s . onload = onAssetLoaded . bind ( this ) ;
68
- s . onerror = onAssetFailed . bind ( this , asset ) ;
69
- s . async = true ;
70
- document . body . appendChild ( s ) ;
71
- this . assetCache [ asset . url ] = s ;
26
+ if ( ! defined ( this . plugins [ data . id ] ) ) {
27
+ if ( data . type === 'issue-tracking' ) {
28
+ this . plugins [ data . id ] = DefaultIssuePlugin ;
72
29
} else {
73
- onAssetLoaded ( ) ;
30
+ this . plugins [ data . id ] = DefaultPlugin ;
74
31
}
75
- } ) ;
32
+ }
33
+ console . info (
34
+ '[plugins] Loaded ' + data . id + ' as {' + this . plugins [ data . id ] . name + '}'
35
+ ) ;
36
+ callback ( this . get ( data ) ) ;
76
37
}
77
38
78
39
get ( data : Plugin ) {
0 commit comments