Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove "Occasional Updates" toggle from profile page #2394

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions packages/client/src/components/EmailSettingsBanner.vue

This file was deleted.

3 changes: 1 addition & 2 deletions packages/client/src/components/Modals/ProfileSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
methods: {
...mapActions({
changeSelectedAgency: 'users/changeSelectedAgency',
updateEmailSubscriptionPreferences: 'users/updateEmailSubscriptionPreferences',
updateEmailSubscriptionPreferences: 'users/updateEmailSubscriptionPreferencesForLoggedInUser',
}),
resetModal() {
this.$emit('update:showModal', false);
Expand All @@ -103,7 +103,6 @@ export default {
};
data.forEach((notificationType) => { updatedPreferences[notificationType] = 'SUBSCRIBED'; });
this.updateEmailSubscriptionPreferences({
userId: this.loggedInUser.id,
preferences: updatedPreferences,
});
},
Expand Down
5 changes: 2 additions & 3 deletions packages/client/src/store/modules/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ export default {
}
await dispatch('fetchUsers');
},
async updateEmailSubscriptionPreferences({ dispatch, commit }, { userId, preferences }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All existing uses of this method were being called on the logged in user, plus line 89 below clearly assumes that the method is only called on the logged in user, so I updated the method to only apply to the logged in user.

async updateEmailSubscriptionPreferencesForLoggedInUser({ commit, getters }, { preferences }) {
const data = await fetchApi.put(
`/api/organizations/:organizationId/users/${userId}/email_subscription`,
`/api/organizations/:organizationId/users/${getters.loggedInUser.id}/email_subscription`,
{
preferences,
},
);
commit('SET_LOGGED_IN_USER', data.user);
dispatch('fetchUsers');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API call was returning '403 - Forbidden' with my test user. I think only admin users are permitted to fetch users. But it's safe to remove this call since the previous line updates the store for the modified user.

},
},
mutations: {
Expand Down
8 changes: 1 addition & 7 deletions packages/client/src/views/MyProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ export default {
key: 'GRANT_ASSIGNMENT',
description: 'Send me notifications if a grant has been assigned to my USDR Grants team.',
},
{
name: 'Occasional Updates',
key: 'GRANT_FINDER_UPDATES',
description: 'Send me occasional emails about feature releases, surveys, and other updates.',
},
],
breadcrumb_items: [
{
Expand Down Expand Up @@ -98,15 +93,14 @@ export default {
},
methods: {
...mapActions({
updateEmailSubscriptionPreferences: 'users/updateEmailSubscriptionPreferences',
updateEmailSubscriptionPreferences: 'users/updateEmailSubscriptionPreferencesForLoggedInUser',
}),
onUpdateEmailPreference(pref) {
const updatedPreferences = {
...this.emailPreferences,
[pref.key]: pref.checked ? 'SUBSCRIBED' : 'UNSUBSCRIBED',
};
this.updateEmailSubscriptionPreferences({
userId: this.loggedInUser.id,
preferences: updatedPreferences,
});
},
Expand Down
Loading