Created
November 16, 2016 14:45
-
-
Save sAbakumoff/922a78b79f84855596df9d3f378250cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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