267267 var countly_newsletter = doc . countly_newsletter ;
268268 delete doc . countly_newsletter ;
269269
270- this . $store . dispatch ( 'countlyOnboarding/updateUserNewsletter' , {
271- user_id : countlyGlobal . member . _id ,
272- subscribe_newsletter : countly_newsletter ,
273- } ) ;
274-
275270 if ( countly_newsletter ) {
276271 this . $store . dispatch ( 'countlyOnboarding/sendNewsletterSubscription' , {
277272 name : countlyGlobal . member . full_name . split ( ' ' ) [ 0 ] ,
280275 } ) ;
281276 }
282277
283- // go home
284- window . location . href = '#/home' ;
285- window . location . reload ( ) ;
278+ this . $store . dispatch ( 'countlyOnboarding/updateUserNewsletter' , {
279+ user_id : countlyGlobal . member . _id ,
280+ subscribe_newsletter : countly_newsletter ,
281+ } ) . finally ( function ( ) {
282+ countlyGlobal . member . subscribe_newsletter = countly_newsletter ;
283+ // go home
284+ window . location . href = '#/home' ;
285+ window . location . reload ( ) ;
286+ } ) ;
286287 } ,
287288 }
288289 } ) ;
345346 }
346347 } ) ;
347348
348- if ( hasNewsLetter && ( typeof countlyGlobal . member . subscribe_newsletter !== 'boolean' && ! store . get ( 'disable_newsletter_prompt' ) && ( countlyGlobal . member . login_count === 3 || moment ( ) . dayOfYear ( ) % 90 === 0 ) ) ) {
349+ if (
350+ hasNewsLetter &&
351+ (
352+ typeof countlyGlobal . member . subscribe_newsletter !== 'boolean' &&
353+ store . get ( 'disable_newsletter_prompt' ) === false &&
354+ ( countlyGlobal . member . login_count === 3 || moment ( ) . dayOfYear ( ) % 90 === 0 )
355+ )
356+ ) {
349357 if ( Backbone . history . fragment !== '/not-subscribed-newsletter' && ! / i n i t i a l - s e t u p | i n i t i a l - c o n s e n t / . test ( window . location . hash ) ) {
350358 app . navigate ( "/not-subscribed-newsletter" , true ) ;
351359 }
352360 }
353361 else if ( ! countlyGlobal . member . subscribe_newsletter && ( countlyGlobal . member . login_count !== 3 && moment ( ) . dayOfYear ( ) % 90 !== 0 ) ) {
354362 store . set ( 'disable_newsletter_prompt' , false ) ;
355363 }
356- } ) ( ) ;
364+ } ) ( ) ;
0 commit comments