UNPKG

poi-plugin-lock-reminder

Version:

A poi plugin for reminding to lock new kanmusu.

50 lines (41 loc) 2.91 kB
"use strict"; exports.__esModule = true; exports.unownedShipsSelector = exports.selectedShipsSelector = exports.selectedShipIdsSelector = exports.pictureUnownedShipsSelector = exports.pictureModeShouldNotifiedSelector = exports.originShipsSelector = exports.customModeShouldNotifiedSelector = void 0; var _lodash = _interopRequireDefault(require("lodash")); var _selectors = require("views/utils/selectors"); var _selectors2 = require("subtender/poi/selectors"); var _reselect = require("reselect"); var _utils = require("../utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const unownedShipsSelector = (0, _reselect.createSelector)(_selectors.shipsSelector, _selectors.constSelector, _selectors2.shipRemodelInfoSelector, (ships, { $ships }, { remodelChains, originMstIdOf }) => _lodash.default.map(_lodash.default.filter(_lodash.default.keys(remodelChains), id => !_lodash.default.find(ships, s => +id === +originMstIdOf[String(s.api_ship_id)])), id => $ships[id])); exports.unownedShipsSelector = unownedShipsSelector; const originShipsSelector = (0, _reselect.createSelector)(_selectors.constSelector, _selectors2.shipRemodelInfoSelector, ({ $ships }, { remodelChains }) => _lodash.default.map(_lodash.default.keys(remodelChains), k => _lodash.default.find($ships, s => +s.api_id === +k))); exports.originShipsSelector = originShipsSelector; const pictureUnownedShipsSelector = (0, _reselect.createSelector)([(0, _selectors.extensionSelectorFactory)(_utils.PLUGIN_NAME), unownedShipsSelector], ({ picture: pictureOwnedShipIds }, uShips) => { if (_lodash.default.isEmpty(pictureOwnedShipIds)) { return uShips; } return _lodash.default.filter(uShips, us => _lodash.default.indexOf(_lodash.default.map(pictureOwnedShipIds, id => +id), +us.api_id) === -1); }); exports.pictureUnownedShipsSelector = pictureUnownedShipsSelector; const selectedShipIdsSelector = (0, _reselect.createSelector)(_selectors.configSelector, config => _lodash.default.get(config, _utils.CONFIG_PATH, [])); exports.selectedShipIdsSelector = selectedShipIdsSelector; const selectedShipsSelector = (0, _reselect.createSelector)(selectedShipIdsSelector, _selectors.constSelector, (ids, { $ships }) => _lodash.default.map(ids, id => _lodash.default.find($ships, s => +s.api_id === +id))); exports.selectedShipsSelector = selectedShipsSelector; const customModeShouldNotifiedSelector = (0, _reselect.createSelector)([unownedShipsSelector, selectedShipIdsSelector], (uShips, sShipIds) => _lodash.default.filter(uShips, ship => _lodash.default.indexOf(sShipIds, +ship.api_id) === -1)); exports.customModeShouldNotifiedSelector = customModeShouldNotifiedSelector; const pictureModeShouldNotifiedSelector = (0, _reselect.createSelector)(pictureUnownedShipsSelector, ships => ships); exports.pictureModeShouldNotifiedSelector = pictureModeShouldNotifiedSelector;