File tree Expand file tree Collapse file tree 2 files changed +22
-18
lines changed Expand file tree Collapse file tree 2 files changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -128,25 +128,18 @@ export default Controller.extend({
128
128
} ) ,
129
129
130
130
loadReadmeTask : task ( function * ( ) {
131
- if ( this . currentVersion . get ( 'readme_path' ) ) {
132
- try {
133
- let r = yield fetch ( this . currentVersion . get ( 'readme_path' ) ) ;
134
- if ( r . ok ) {
135
- this . crate . set ( 'readme' , yield r . text ( ) ) ;
136
-
137
- if ( typeof document !== 'undefined' ) {
138
- setTimeout ( ( ) => {
139
- let e = document . createEvent ( 'CustomEvent' ) ;
140
- e . initCustomEvent ( 'hashchange' , true , true ) ;
141
- window . dispatchEvent ( e ) ;
142
- } ) ;
143
- }
144
- } else {
145
- this . crate . set ( 'readme' , null ) ;
146
- }
147
- } catch ( error ) {
148
- this . crate . set ( 'readme' , null ) ;
131
+ try {
132
+ this . crate . set ( 'readme' , yield this . currentVersion . loadReadmeTask . perform ( ) ) ;
133
+
134
+ if ( typeof document !== 'undefined' ) {
135
+ setTimeout ( ( ) => {
136
+ let e = document . createEvent ( 'CustomEvent' ) ;
137
+ e . initCustomEvent ( 'hashchange' , true , true ) ;
138
+ window . dispatchEvent ( e ) ;
139
+ } ) ;
149
140
}
141
+ } catch ( error ) {
142
+ this . crate . set ( 'readme' , null ) ;
150
143
}
151
144
} ) ,
152
145
Original file line number Diff line number Diff line change @@ -39,4 +39,15 @@ export default Model.extend({
39
39
40
40
return { normal, build, dev } ;
41
41
} ) . keepLatest ( ) ,
42
+
43
+ loadReadmeTask : task ( function * ( ) {
44
+ if ( this . readme_path ) {
45
+ let response = yield fetch ( this . readme_path ) ;
46
+ if ( ! response . ok ) {
47
+ throw new Error ( `README request for ${ this . crateName } v${ this . num } failed` ) ;
48
+ }
49
+
50
+ return yield response . text ( ) ;
51
+ }
52
+ } ) . keepLatest ( ) ,
42
53
} ) ;
You can’t perform that action at this time.
0 commit comments