Fix unsubscribe all update
This commit is contained in:
parent
79af4b2be0
commit
6ac467764d
|
@ -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'
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user