Skip to content

Instantly share code, notes, and snippets.

@sAbakumoff
Last active November 16, 2016 13:32
Show Gist options
  • Save sAbakumoff/c18859b89e716a0d165609032c858f4b to your computer and use it in GitHub Desktop.
Save sAbakumoff/c18859b89e716a0d165609032c858f4b 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';
const sharePostStatus = {
[ PUBLICIZE_SHARE ]: ( state, { siteId, postId } ) =>
( { ...state, [ siteId ]: { ...state[ siteId ], [ postId ]: {
requesting: true,
} } } ),
[ PUBLICIZE_SHARE_SUCCESS ]: ( state, { siteId, postId } ) =>
( { ...state, [ siteId ]: { ...state[ siteId ], [ postId ]: {
requesting: false,
success: true,
} } } ),
[ PUBLICIZE_SHARE_FAILURE ]: ( state, { siteId, postId, error } ) =>
( { ...state, [ siteId ]: { ...state[ siteId ], [ postId ]: {
requesting: false,
success: false,
error,
} } } ),
[ PUBLICIZE_SHARE_DISMISS ]: ( state, { siteId, postId } ) =>
( { ...state, [ siteId ]: {
...state[ siteId ], [ postId ]: undefined
} } ),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment