UNPKG

poi-plugin-lock-reminder

Version:

A poi plugin for reminding to lock new kanmusu.

51 lines (38 loc) 1.82 kB
"use strict"; exports.__esModule = true; exports.logger = exports.canBePushed = exports.PLUGIN_NAME = exports.CONFIG_PATH = void 0; var _lodash = _interopRequireDefault(require("lodash")); var _package = _interopRequireDefault(require("./package.json")); var _selectors = require("./views/selectors"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const { getStore, dbg } = window; const PLUGIN_NAME = _package.default.name; exports.PLUGIN_NAME = PLUGIN_NAME; const logger = dbg.extra(PLUGIN_NAME); exports.logger = logger; const canBePushed = shipId => { logger.log('shipId', shipId); if (!shipId) { return false; } const mode = getStore(`config.plugin.${PLUGIN_NAME}.mode`) || 'custom'; const category = getStore(`config.plugin.${PLUGIN_NAME}.customNotifyCategory`) || 'willnot'; const customModeSelectedShips = (0, _selectors.selectedShipsSelector)(getStore()); const customModeUnownedShips = (0, _selectors.customModeShouldNotifiedSelector)(getStore()); const pictureModeShouldNotifiedShips = (0, _selectors.pictureModeShouldNotifiedSelector)(getStore()); logger.log('customModeSelectedShips', customModeSelectedShips); logger.log('customModeShouldNotifiedShips', customModeUnownedShips); logger.log('pictureModeShouldNotifiedShips', pictureModeShouldNotifiedShips); const shipIsIn = group => _lodash.default.some(group, s => +s.api_id === +shipId); if (mode === 'custom') { logger.log('custom mode, category ', category); return category === 'willnot' ? shipIsIn(customModeUnownedShips) : shipIsIn(customModeSelectedShips); } return shipIsIn(pictureModeShouldNotifiedShips); }; exports.canBePushed = canBePushed; const CONFIG_PATH = `plugin.${PLUGIN_NAME}.selectedShips`; exports.CONFIG_PATH = CONFIG_PATH;