Feat(privacy): Add granular privacy controls of public profile (#17178)

* feat(privacy): Add granular privacy controls of public profile

* feat(certs): Hide certs if showCerts is false
This commit is contained in:
Stuart Taylor
2018-05-20 04:07:41 +01:00
committed by Quincy Larson
parent a1f2fc7c5c
commit bb4bcbfb45
17 changed files with 441 additions and 95 deletions

View File

@@ -5,7 +5,8 @@ import {
types,
refetchCompletedChallenges,
updateUserBackendComplete,
updateMyPortfolioComplete
updateMyPortfolioComplete,
updateMyProfileUIComplete
} from './';
import { makeToast } from '../../../Toasts/redux';
import {
@@ -18,7 +19,8 @@ import {
updateUserEmail,
updateMultipleUserFlags,
regresPortfolio,
optoUpdatePortfolio
optoUpdatePortfolio,
updateLocalProfileUI
} from '../../../entities';
import { postJSON$ } from '../../../../utils/ajax-stream';
@@ -188,9 +190,41 @@ function updateUserEmailEpic(actions, { getState }) {
});
}
function updateMyProfileUIEpic(action$, { getState }) {
const toggle = action$::ofType(types.updateMyProfileUI.start);
const server = toggle.flatMap(({payload: { profileUI }}) => {
const state = getState();
const { csrfToken: _csrf } = state.app;
const username = usernameSelector(state);
const oldUI = { ...userSelector(state).profileUI };
return postJSON$('/update-my-profile-ui', { _csrf, profileUI })
.map(updateMyProfileUIComplete)
.catch(
doActionOnError(
() => Observable.of(
makeToast({
message:
'Something went wrong saving your privacy settings, ' +
'please try again.'
}),
updateLocalProfileUI({username, profileUI: oldUI })
)
)
);
});
const optimistic = toggle.flatMap(({payload: { profileUI }}) => {
const username = usernameSelector(getState());
return Observable.of(updateLocalProfileUI({username, profileUI}));
});
return Observable.merge(server, optimistic);
}
export default combineEpics(
backendUserUpdateEpic,
refetchCompletedChallengesEpic,
updateMyPortfolioEpic,
updateUserEmailEpic
updateUserEmailEpic,
updateMyProfileUIEpic
);