Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
'use strict';
var _sharePostStatus;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var PUBLICIZE_SHARE = 'PUBLICIZE_SHARE';
var PUBLICIZE_SHARE_SUCCESS = 'PUBLICIZE_SHARE_SUCCESS';
var PUBLICIZE_SHARE_FAILURE = 'PUBLICIZE_SHARE_FAILURE';
var 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 = (_sharePostStatus = {}, _defineProperty(_sharePostStatus, PUBLICIZE_SHARE, function (state, action) {
return update(state, action, { requesting: true });
}), _defineProperty(_sharePostStatus, PUBLICIZE_SHARE_SUCCESS, function (state, action) {
return update(state, action, { requesting: false, success: true });
}), _defineProperty(_sharePostStatus, PUBLICIZE_SHARE_FAILURE, function (state, action) {
return update(state, action, { requesting: false, success: false, error: action.error });
}), _defineProperty(_sharePostStatus, PUBLICIZE_SHARE_DISMISS, function (state, action) {
return update(state, action, undefined);
}), _sharePostStatus);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment