Skip to content

Instantly share code, notes, and snippets.

@sAbakumoff
Created November 16, 2016 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sAbakumoff/922a78b79f84855596df9d3f378250cf to your computer and use it in GitHub Desktop.
Save sAbakumoff/922a78b79f84855596df9d3f378250cf to your computer and use it in GitHub Desktop.
const PUBLICIZE_SHARE = 'PUBLICIZE_SHARE';
const PUBLICIZE_SHARE_SUCCESS = 'PUBLICIZE_SHARE_SUCCESS';
const PUBLICIZE_SHARE_FAILURE = 'PUBLICIZE_SHARE_FAILURE';
const PUBLICIZE_SHARE_DISMISS = 'PUBLICIZE_SHARE_DISMISS';
function update(state, action, post_status){
var next_state = Object.assign({}, state);
var post = {};
post[action.postId] = post_status;
next_state[action.siteId] = Object.assign({}, next_state[action.siteId], post);
return next_state;
};
var sharePostStatus = {
[PUBLICIZE_SHARE] : (state, action)=>update(state, action, {requesting: true}),
[PUBLICIZE_SHARE_SUCCESS] : (state, action)=>update(state, action, {requesting: false, success: true}),
[PUBLICIZE_SHARE_FAILURE] : (state, action)=>update(state, action, {requesting: false, success: false, error : action.error}),
[PUBLICIZE_SHARE_DISMISS] : (state, action)=>update(state, action, undefined)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment