Fix unsubscribe all update

This commit is contained in:
Ian Philips 2022-10-04 08:38:20 -06:00
parent 79af4b2be0
commit 6ac467764d

View File

@ -34,17 +34,20 @@ export const unsubscribe: EndpointDefinition = {
const previousDestinations = const previousDestinations =
user.notificationPreferences[notificationSubscriptionType] user.notificationPreferences[notificationSubscriptionType]
let newDestinations = previousDestinations
if (wantsToOptOutAll) newDestinations.push('email')
else
newDestinations = previousDestinations.filter(
(destination) => destination !== 'email'
)
console.log(previousDestinations) console.log(previousDestinations)
const { email } = user const { email } = user
const update: Partial<PrivateUser> = { const update: Partial<PrivateUser> = {
notificationPreferences: { notificationPreferences: {
...user.notificationPreferences, ...user.notificationPreferences,
[notificationSubscriptionType]: wantsToOptOutAll [notificationSubscriptionType]: newDestinations,
? previousDestinations.push('email')
: previousDestinations.filter(
(destination) => destination !== 'email'
),
}, },
} }