1
- import Service from '@ember/service' ;
1
+ import Service , { inject as service } from '@ember/service' ;
2
2
import { isPresent } from '@ember/utils' ;
3
3
import { set } from '@ember/object' ;
4
4
import { A } from '@ember/array' ;
5
5
import getCompactVersion from 'ember-api-docs/utils/get-compact-version' ;
6
6
import getLastVersion from 'ember-api-docs/utils/get-last-version' ;
7
7
8
8
export default Service . extend ( {
9
+ fastboot : service ( ) ,
9
10
10
11
availableProjectVersions : null ,
11
12
projectRevMap : null ,
12
13
13
14
init ( ) {
15
+ this . _super ( ...arguments ) ;
16
+
17
+ if ( this . fastboot . isFastBoot ) {
18
+ this . createProperties ( ) ;
19
+ this . updateShoebox ( ) ;
20
+ } else {
21
+ this . availableProjectVersions = this . fastboot . shoebox . retrieve ( 'availableProjectVersions' ) ;
22
+ this . projectRevMap = this . fastboot . shoebox . retrieve ( 'projectRevMap' ) ;
23
+ }
24
+
25
+ if ( ! this . availableProjectVersions || ! this . projectRevMap ) {
26
+ this . createProperties ( ) ;
27
+ }
28
+ } ,
29
+
30
+ createProperties ( ) {
14
31
this . availableProjectVersions = {
15
32
'ember' : A ( ) ,
16
33
'ember-data' :A ( )
17
34
} ;
18
35
this . projectRevMap = { } ;
19
- this . _super ( ...arguments ) ;
36
+ } ,
37
+
38
+ updateShoebox ( ) {
39
+ if ( this . fastboot . isFastBoot ) {
40
+ this . fastboot . shoebox . put ( 'availableProjectVersions' , this . availableProjectVersions ) ;
41
+ this . fastboot . shoebox . put ( 'projectMap' , this . projectRevMap ) ;
42
+ }
20
43
} ,
21
44
22
45
addToProjectRevMap ( projectVersionKey , projectRevDoc ) {
23
46
let projectRevMap = this . projectRevMap ;
24
47
if ( ! isPresent ( projectRevMap [ projectVersionKey ] ) ) {
25
48
projectRevMap [ projectVersionKey ] = projectRevDoc ;
26
49
set ( this , 'projectRevMap' , projectRevMap ) ;
50
+ this . updateShoebox ( ) ;
27
51
}
28
52
} ,
29
53
@@ -43,7 +67,8 @@ export default Service.extend({
43
67
'ember-data' : A ( availableProjectVersions [ 'ember-data' ] )
44
68
} ,
45
69
projectRevMap : projectRevMap
46
- } )
70
+ } ) ;
71
+ this . updateShoebox ( ) ;
47
72
} ,
48
73
49
74
getFullVersion ( projectName , compactProjVersion ) {
0 commit comments