Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 945e34d

Browse files
author
vikasrohit
committed
Merge pull request #789 from appirio-tech/dev
Handled case where user is not in the required mailing list and opens the email settings page
2 parents 1a79c7a + 4d61757 commit 945e34d

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

app/settings/email/email.controller.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,25 @@ import angular from 'angular'
5656
]
5757

5858
vm.loading = true
59-
MailchimpService.getMemberSubscription(userProfile).then(function(resp) {
59+
return MailchimpService.getMemberSubscription(userProfile).then(function(subscription) {
6060
vm.loading = false
61-
if (resp.interests) {
62-
vm.newsletters.forEach(function(newsletter) {
63-
if (resp.interests[newsletter.id]) {
64-
newsletter.enabled = true
65-
}
61+
if (!subscription) {
62+
// add member to the list with empty preferences
63+
MailchimpService.addSubscription(userProfile, {}).then(function(resp) {
64+
logger.debug(resp)
65+
}).catch(function(err) {
66+
// no error to user
67+
//TODO some error alert to community admin
68+
logger.debug('error in adding user to member list')
6669
})
70+
} else {
71+
if (subscription.interests) {
72+
vm.newsletters.forEach(function(newsletter) {
73+
if (subscription.interests[newsletter.id]) {
74+
newsletter.enabled = true
75+
}
76+
})
77+
}
6778
}
6879
})
6980
}

0 commit comments

Comments
 (0)