@@ -5,9 +5,9 @@ import angular from 'angular'
55
66 angular . module ( 'tc.settings' ) . controller ( 'EmailSettingsController' , EmailSettingsController )
77
8- EmailSettingsController . $inject = [ '$rootScope' , 'userData' , 'ProfileService' , 'MailchimpService ' , 'logger' , 'CONSTANTS' , 'toaster' , '$q' , '$scope' ]
8+ EmailSettingsController . $inject = [ '$rootScope' , 'userData' , 'ProfileService' , 'UserPreferencesService ' , 'logger' , 'CONSTANTS' , 'toaster' , '$q' , '$scope' ]
99
10- function EmailSettingsController ( $rootScope , userData , ProfileService , MailchimpService , logger , CONSTANTS , toaster , $q , $scope ) {
10+ function EmailSettingsController ( $rootScope , userData , ProfileService , UserPreferencesService , logger , CONSTANTS , toaster , $q , $scope ) {
1111 var vm = this
1212 vm . loading = false
1313 vm . saving = false
@@ -19,42 +19,42 @@ import angular from 'angular'
1919 function activate ( ) {
2020 vm . newsletters = [
2121 {
22- id : CONSTANTS . MAILCHIMP_NL_GEN ,
22+ id : 'TOPCODER_NL_GEN' ,
2323 name : 'General Newsletter' ,
2424 desc : 'News summary from all tracks and programs' ,
2525 enabled : false ,
2626 dirty : false
2727 } ,
2828 {
29- id : CONSTANTS . MAILCHIMP_NL_DESIGN ,
29+ id : 'TOPCODER_NL_DESIGN' ,
3030 name : 'Design Newsletter' ,
3131 desc : 'Website, mobile, and product design; UI and UX' ,
3232 enabled : false ,
3333 dirty : false
3434 } ,
3535 {
36- id : CONSTANTS . MAILCHIMP_NL_DEV ,
36+ id : 'TOPCODER_NL_DEV' ,
3737 name : 'Development Newsletter' ,
3838 desc : 'Software architecture, component assembly, application development, and bug hunting' ,
3939 enabled : false ,
4040 dirty : false
4141 } ,
4242 {
43- id : CONSTANTS . MAILCHIMP_NL_DATA ,
43+ id : 'TOPCODER_NL_DATA' ,
4444 name : 'Data Science Newsletter' ,
4545 desc : 'Algorithm and data structures, statistical analysis' ,
4646 enabled : false ,
4747 dirty : false
4848 } ,
4949 {
50- id : CONSTANTS . MAILCHIMP_NL_IOS ,
50+ id : 'TOPCODER_NL_IOS' ,
5151 name : 'iOS Community Newsletter' ,
5252 desc : 'Mobile app design and development for iOS, with Swift emphasis' ,
5353 enabled : false ,
5454 dirty : false
5555 } ,
5656 {
57- id : CONSTANTS . MAILCHIMP_NL_TCO ,
57+ id : 'TOPCODER_NL_TCO' ,
5858 name : 'TCO Newsletter' ,
5959 desc : 'Our annual online and onsite tournament to celebrate and reward the community' ,
6060 enabled : false ,
@@ -63,21 +63,21 @@ import angular from 'angular'
6363 ]
6464
6565 vm . loading = true
66- return MailchimpService . getMemberSubscription ( userData ) . then ( function ( subscription ) {
66+ return UserPreferencesService . getEmailPreferences ( userData ) . then ( function ( subscription ) {
6767 vm . loading = false
6868 if ( ! subscription ) {
6969 // add member to the list with default preferences
70- MailchimpService . addSubscription ( userData , { } ) . then ( function ( resp ) {
70+ UserPreferencesService . saveEmailPreferences ( userData , { } ) . then ( function ( resp ) {
7171 logger . debug ( resp )
7272 } ) . catch ( function ( err ) {
7373 // no error to user
7474 //TODO some error alert to community admin
7575 logger . debug ( 'error in adding user to member list' )
7676 } )
7777 } else {
78- if ( subscription . interests ) {
78+ if ( subscription ) {
7979 vm . newsletters . forEach ( function ( newsletter ) {
80- if ( subscription . interests [ newsletter . id ] ) {
80+ if ( subscription [ newsletter . id ] ) {
8181 newsletter . enabled = true
8282 }
8383 } )
@@ -102,7 +102,7 @@ import angular from 'angular'
102102 vm . newsletters . forEach ( function ( newsletter ) {
103103 preferences [ newsletter . id ] = newsletter . enabled
104104 } )
105- MailchimpService . addSubscription ( userData , preferences ) . then ( function ( resp ) {
105+ UserPreferencesService . saveEmailPreferences ( userData , preferences ) . then ( function ( resp ) {
106106 vm . loading = false
107107 vm . saving = false
108108 // reset dirty state for all newsletter options
0 commit comments