@@ -87,9 +87,16 @@ define([
87
87
} : [ ] ;
88
88
parameters [ 'update_section_id' ] = updateSectionId ;
89
89
90
- return $ . getJSON ( options . sectionLoadUrl , parameters ) . fail ( function ( jqXHR ) {
91
- throw new Error ( jqXHR ) ;
92
- } ) ;
90
+ return $ . getJSON ( options . sectionLoadUrl , parameters )
91
+ . done (
92
+ function ( ) {
93
+ if ( _ . isEmpty ( sectionNames ) ) {
94
+ customerData . set ( 'is_loading' , false ) ;
95
+ }
96
+ }
97
+ ) . fail ( function ( jqXHR ) {
98
+ throw new Error ( jqXHR ) ;
99
+ } ) ;
93
100
}
94
101
} ;
95
102
@@ -199,7 +206,8 @@ define([
199
206
privateContent = $ . cookieStorage . get ( privateContentVersion ) ,
200
207
localPrivateContent = $ . localStorage . get ( privateContentVersion ) ,
201
208
needVersion = 'need_version' ,
202
- expiredSectionNames = this . getExpiredSectionNames ( ) ;
209
+ expiredSectionNames = this . getExpiredSectionNames ( ) ,
210
+ isLoading = false ;
203
211
204
212
if ( privateContent &&
205
213
! $ . cookieStorage . isSet ( privateContentVersion ) &&
@@ -208,13 +216,15 @@ define([
208
216
$ . cookieStorage . set ( privateContentVersion , needVersion ) ;
209
217
$ . localStorage . set ( privateContentVersion , needVersion ) ;
210
218
this . reload ( [ ] , false ) ;
219
+ this . set ( 'is_loading' , true ) ;
211
220
} else if ( localPrivateContent !== privateContent ) {
212
221
if ( ! $ . cookieStorage . isSet ( privateContentVersion ) ) {
213
222
privateContent = needVersion ;
214
223
$ . cookieStorage . set ( privateContentVersion , privateContent ) ;
215
224
}
216
225
$ . localStorage . set ( privateContentVersion , privateContent ) ;
217
226
this . reload ( [ ] , false ) ;
227
+ this . set ( 'is_loading' , true ) ;
218
228
} else if ( expiredSectionNames . length > 0 ) {
219
229
_ . each ( dataProvider . getFromStorage ( storage . keys ( ) ) , function ( sectionData , sectionName ) {
220
230
buffer . notify ( sectionName , sectionData ) ;
@@ -232,8 +242,9 @@ define([
232
242
233
243
if ( ! _ . isEmpty ( privateContent ) ) {
234
244
countryData = this . get ( 'directory-data' ) ;
245
+ isLoading = this . get ( 'is_loading' ) ;
235
246
236
- if ( _ . isEmpty ( countryData ( ) ) ) {
247
+ if ( _ . isEmpty ( countryData ( ) ) && ! isLoading ) {
237
248
customerData . reload ( [ 'directory-data' ] , false ) ;
238
249
}
239
250
}
@@ -328,7 +339,6 @@ define([
328
339
*/
329
340
reload : function ( sectionNames , updateSectionId ) {
330
341
return dataProvider . getFromServer ( sectionNames , updateSectionId ) . done ( function ( sections ) {
331
- $ ( document ) . trigger ( 'customer-data-reload' , [ sectionNames ] ) ;
332
342
buffer . update ( sections ) ;
333
343
} ) ;
334
344
} ,
0 commit comments