UNPKG

@stackend/api

Version:

JS bindings to api.stackend.com

52 lines 1.87 kB
"use strict"; // @flow Object.defineProperty(exports, "__esModule", { value: true }); exports.RESET_MODULES = exports.RECEIVE_MODULES = exports.REQUEST_MODULES = void 0; exports.REQUEST_MODULES = 'REQUEST_MODULES'; exports.RECEIVE_MODULES = 'RECEIVE_MODULES'; exports.RESET_MODULES = 'RESET_MODULES'; //Reducer function moduleReducer(state, action) { if (state === void 0) { state = { moduleIds: [], modulesById: {} }; } switch (action.type) { case exports.REQUEST_MODULES: return Object.assign({}, state, { isFetching: true, didInvalidate: false }); case exports.RECEIVE_MODULES: { var moduleIds = []; for (var _i = 0, _a = Object.keys(action.data.modules); _i < _a.length; _i++) { var key = _a[_i]; moduleIds.push(key); } return Object.assign({}, state, { isFetching: false, didInvalidate: false, lastUpdated: action.receivedAt, modulesById: action.data.modules, moduleIds: moduleIds, stats: action.data.stats || state.supportedModuleContexts, supportedModuleContexts: action.data.supportedModuleContexts || state.supportedModuleContexts }); } case exports.RESET_MODULES: return Object.assign({}, state, { isFetching: false, didInvalidate: false, modulesById: {}, moduleIds: [], stats: undefined, communityId: 0, supportedModuleContexts: undefined, __relatedObjects: {} }); default: return state; } } exports.default = moduleReducer; //# sourceMappingURL=moduleReducer.js.map