poi-plugin-milk 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,7 +41,7 @@
41
41
  </provider>
42
42
  </entry>
43
43
  </file>
44
- <file leaf-file-name="factor.js" pinned="false" current-in-tab="false">
44
+ <file leaf-file-name="factor.js" pinned="false" current-in-tab="true">
45
45
  <entry file="file://$PROJECT_DIR$/parts/factor.js">
46
46
  <provider selected="true" editor-type-id="text-editor">
47
47
  <state relative-caret-position="0">
@@ -64,8 +64,8 @@
64
64
  <file leaf-file-name="zh-CN.json" pinned="false" current-in-tab="false">
65
65
  <entry file="file://$PROJECT_DIR$/i18n/zh-CN.json">
66
66
  <provider selected="true" editor-type-id="text-editor">
67
- <state relative-caret-position="41">
68
- <caret line="1" column="28" lean-forward="false" selection-start-line="1" selection-start-column="28" selection-end-line="1" selection-end-column="28" />
67
+ <state relative-caret-position="943">
68
+ <caret line="23" column="1" lean-forward="true" selection-start-line="23" selection-start-column="1" selection-end-line="23" selection-end-column="1" />
69
69
  <folding />
70
70
  </state>
71
71
  </provider>
@@ -84,7 +84,7 @@
84
84
  </provider>
85
85
  </entry>
86
86
  </file>
87
- <file leaf-file-name="package.json" pinned="false" current-in-tab="true">
87
+ <file leaf-file-name="package.json" pinned="false" current-in-tab="false">
88
88
  <entry file="file://$PROJECT_DIR$/package.json">
89
89
  <provider selected="true" editor-type-id="text-editor">
90
90
  <state relative-caret-position="82">
@@ -124,10 +124,10 @@
124
124
  <find>HP</find>
125
125
  <find>inRepair</find>
126
126
  <find>timeElapsed</find>
127
- <find>49</find>
128
- <find>49a</find>
129
- <find>poi-util-transpile</find>
130
127
  <find>repairId</find>
128
+ <find>poi-util-transpile</find>
129
+ <find>49a</find>
130
+ <find>49</find>
131
131
  </findStrings>
132
132
  </component>
133
133
  <component name="IdeDocumentHistory">
@@ -137,8 +137,8 @@
137
137
  <option value="$PROJECT_DIR$/parts/fleet-list.js" />
138
138
  <option value="$PROJECT_DIR$/parts/ship-row.js" />
139
139
  <option value="$PROJECT_DIR$/index.js" />
140
- <option value="$PROJECT_DIR$/i18n/zh-CN.json" />
141
140
  <option value="$PROJECT_DIR$/package.json" />
141
+ <option value="$PROJECT_DIR$/i18n/zh-CN.json" />
142
142
  </list>
143
143
  </option>
144
144
  </component>
@@ -262,12 +262,12 @@
262
262
  <option name="presentableId" value="Default" />
263
263
  <updated>1764751942683</updated>
264
264
  <workItem from="1764751943836" duration="336000" />
265
- <workItem from="1764814660477" duration="9279000" />
265
+ <workItem from="1764814660477" duration="9930000" />
266
266
  </task>
267
267
  <servers />
268
268
  </component>
269
269
  <component name="TimeTrackingManager">
270
- <option name="totallyTimeSpent" value="9615000" />
270
+ <option name="totallyTimeSpent" value="10266000" />
271
271
  </component>
272
272
  <component name="ToolWindowManager">
273
273
  <frame x="140" y="22" width="3700" height="2138" extended-state="0" />
@@ -362,26 +362,26 @@
362
362
  </state>
363
363
  </provider>
364
364
  </entry>
365
- <entry file="file://$PROJECT_DIR$/parts/factor.js">
365
+ <entry file="file://$PROJECT_DIR$/index.js">
366
366
  <provider selected="true" editor-type-id="text-editor">
367
- <state relative-caret-position="0">
368
- <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
367
+ <state relative-caret-position="4264">
368
+ <caret line="102" column="6" lean-forward="false" selection-start-line="102" selection-start-column="6" selection-end-line="102" selection-end-column="6" />
369
369
  <folding />
370
370
  </state>
371
371
  </provider>
372
372
  </entry>
373
- <entry file="file://$PROJECT_DIR$/parts/functions.js">
373
+ <entry file="file://$PROJECT_DIR$/package.json">
374
374
  <provider selected="true" editor-type-id="text-editor">
375
- <state relative-caret-position="973">
376
- <caret line="58" column="56" lean-forward="false" selection-start-line="58" selection-start-column="56" selection-end-line="58" selection-end-column="56" />
375
+ <state relative-caret-position="82">
376
+ <caret line="2" column="19" lean-forward="false" selection-start-line="2" selection-start-column="19" selection-end-line="2" selection-end-column="19" />
377
377
  <folding />
378
378
  </state>
379
379
  </provider>
380
380
  </entry>
381
- <entry file="file://$PROJECT_DIR$/parts/fleet-list.js">
381
+ <entry file="file://$PROJECT_DIR$/i18n/zh-CN.json">
382
382
  <provider selected="true" editor-type-id="text-editor">
383
- <state relative-caret-position="-5995">
384
- <caret line="124" column="51" lean-forward="false" selection-start-line="124" selection-start-column="51" selection-end-line="124" selection-end-column="51" />
383
+ <state relative-caret-position="943">
384
+ <caret line="23" column="1" lean-forward="true" selection-start-line="23" selection-start-column="1" selection-end-line="23" selection-end-column="1" />
385
385
  <folding />
386
386
  </state>
387
387
  </provider>
@@ -394,26 +394,26 @@
394
394
  </state>
395
395
  </provider>
396
396
  </entry>
397
- <entry file="file://$PROJECT_DIR$/index.js">
397
+ <entry file="file://$PROJECT_DIR$/parts/functions.js">
398
398
  <provider selected="true" editor-type-id="text-editor">
399
- <state relative-caret-position="4264">
400
- <caret line="102" column="6" lean-forward="false" selection-start-line="102" selection-start-column="6" selection-end-line="102" selection-end-column="6" />
399
+ <state relative-caret-position="973">
400
+ <caret line="58" column="56" lean-forward="false" selection-start-line="58" selection-start-column="56" selection-end-line="58" selection-end-column="56" />
401
401
  <folding />
402
402
  </state>
403
403
  </provider>
404
404
  </entry>
405
- <entry file="file://$PROJECT_DIR$/i18n/zh-CN.json">
405
+ <entry file="file://$PROJECT_DIR$/parts/fleet-list.js">
406
406
  <provider selected="true" editor-type-id="text-editor">
407
- <state relative-caret-position="41">
408
- <caret line="1" column="28" lean-forward="false" selection-start-line="1" selection-start-column="28" selection-end-line="1" selection-end-column="28" />
407
+ <state relative-caret-position="-5995">
408
+ <caret line="124" column="51" lean-forward="false" selection-start-line="124" selection-start-column="51" selection-end-line="124" selection-end-column="51" />
409
409
  <folding />
410
410
  </state>
411
411
  </provider>
412
412
  </entry>
413
- <entry file="file://$PROJECT_DIR$/package.json">
413
+ <entry file="file://$PROJECT_DIR$/parts/factor.js">
414
414
  <provider selected="true" editor-type-id="text-editor">
415
- <state relative-caret-position="82">
416
- <caret line="2" column="19" lean-forward="false" selection-start-line="2" selection-start-column="19" selection-end-line="2" selection-end-column="19" />
415
+ <state relative-caret-position="0">
416
+ <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
417
417
  <folding />
418
418
  </state>
419
419
  </provider>
package/i18n/zh-CN.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "Anchorage repair": "修理和喂奶",
2
+ "Anchorage repair": "修理&喂奶",
3
3
  "Akashi not flagship": "明石不是旗舰/野崎不是旗舰二舰",
4
4
  "Not ready": "未就绪",
5
5
  "Capacity: %s": "可修理数量: %s",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poi-plugin-milk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Anchorage repair plugin for poi",
5
5
  "main": "index.es",
6
6
  "repository": {
@@ -1,226 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.switchPluginPath = exports.reactClass = undefined;
7
-
8
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
9
-
10
- // Import selectors defined in poi
11
-
12
-
13
- var _react = require('react');
14
-
15
- var _react2 = _interopRequireDefault(_react);
16
-
17
- var _reactRedux = require('react-redux');
18
-
19
- var _reselect = require('reselect');
20
-
21
- var _lodash = require('lodash');
22
-
23
- var _lodash2 = _interopRequireDefault(_lodash);
24
-
25
- var _path = require('path');
26
-
27
- var _reactBootstrap = require('react-bootstrap');
28
-
29
- var _selectors = require('views/utils/selectors');
30
-
31
- var _functions = require('./parts/functions');
32
-
33
- var _fleetList = require('./parts/fleet-list');
34
-
35
- var _fleetList2 = _interopRequireDefault(_fleetList);
36
-
37
- var _candidates = require('./parts/candidates');
38
-
39
- var _candidates2 = _interopRequireDefault(_candidates);
40
-
41
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42
-
43
- const { i18n, getStore } = window;
44
- const __ = i18n['poi-plugin-anchorage-repair'].__.bind(i18n['poi-plugin-anchorage-repair']);
45
-
46
- const AKASHI_ID = [182, 187]; // akashi and kai ID in $ships
47
- const SRF_ID = 86; // Ship Repair Facility ID in $slotitems
48
-
49
-
50
- // check a fleet status, returns information related to anchorage repair
51
- const fleetAkashiConv = (fleet, $ships, ships, equips, repairId) => {
52
- const pickKey = ['api_id', 'api_ship_id', 'api_lv', 'api_nowhp', 'api_maxhp', 'api_ndock_time'];
53
-
54
- let canRepair = false;
55
- let akashiFlagship = false;
56
- let repairCount = 0;
57
- const inExpedition = _lodash2.default.get(fleet, 'api_mission.0') && true;
58
- const flagShipInRepair = _lodash2.default.includes(repairId, _lodash2.default.get(fleet, 'api_ship.0', -1));
59
- const flagship = ships[_lodash2.default.get(fleet, 'api_ship.0', -1)];
60
-
61
- if (flagship != null) {
62
- akashiFlagship = _lodash2.default.includes(AKASHI_ID, flagship.api_ship_id);
63
- repairCount = _lodash2.default.filter(flagship.api_slot, item => _lodash2.default.get(equips, `${item}.api_slotitem_id`, -1) === SRF_ID).length;
64
- repairCount += akashiFlagship ? 2 : 0;
65
- }
66
-
67
- canRepair = akashiFlagship && !inExpedition && !flagShipInRepair;
68
-
69
- const repairDetail = _lodash2.default.map(_lodash2.default.filter(fleet.api_ship, shipId => shipId > 0), (shipId, index) => {
70
- if (shipId === -1) return false; // break, LODASH ONLY
71
-
72
- const ship = _lodash2.default.pick(ships[shipId], pickKey);
73
-
74
- const constShip = _lodash2.default.pick($ships[ship.api_ship_id], ['api_name', 'api_stype']);
75
-
76
- return _extends({}, ship, constShip, {
77
- estimate: (0, _functions.akashiEstimate)(ship),
78
- timePerHP: (0, _functions.getTimePerHP)(ship.api_lv, constShip.api_stype),
79
- inRepair: _lodash2.default.includes(repairId, ship.api_id),
80
- availableSRF: index < repairCount
81
- });
82
- });
83
-
84
- var repairStatus = 0
85
- if(canRepair){
86
- repairStatus = 1;
87
- }else{
88
- var flagshipid = _lodash2.default.get(fleet, 'api_ship.0', -1)
89
- var secondshipid = _lodash2.default.get(fleet, 'api_ship.0', -1)
90
- if(flagshipid==996||flagshipid==1002||secondshipid==996||secondshipid==1002){
91
- repairStatus = 2;
92
- }
93
- }
94
-
95
- return {
96
- api_id: fleet.api_id || -1,
97
- shipId: fleet.api_ship || [],
98
- canRepair,
99
- akashiFlagship,
100
- inExpedition,
101
- flagShipInRepair,
102
- repairCount,
103
- repairDetail
104
- };
105
- };
106
-
107
- // selectors
108
-
109
- const repairIdSelector = (0, _reselect.createSelector)([_selectors.repairsSelector], repair => _lodash2.default.map(repair, dock => dock.api_ship_id));
110
-
111
- const constShipsSelector = state => state.const.$ships || {};
112
-
113
- const fleetsAkashiSelector = (0, _reselect.createSelector)([constShipsSelector, _selectors.fleetsSelector, _selectors.shipsSelector, _selectors.equipsSelector, repairIdSelector], ($ships, fleets, ships, equips, repairId) => ({ fleets: _lodash2.default.map(fleets, fleet => fleetAkashiConv(fleet, $ships, ships, equips, repairId)) })
114
-
115
- // React
116
-
117
- );const reactClass = exports.reactClass = (0, _reactRedux.connect)((0, _selectors.createDeepCompareArraySelector)([fleetsAkashiSelector, _selectors.miscSelector], (data, { canNotify }) => _extends({}, data, {
118
- canNotify
119
- })))(class PluginAnchorageRepair extends _react.Component {
120
-
121
- constructor(props) {
122
- super(props);
123
-
124
- this.handleSelectTab = key => {
125
- this.setState({ activeTab: key });
126
- };
127
-
128
- this.handleSort = index => () => {
129
- this.setState({
130
- sortIndex: index
131
- });
132
- };
133
-
134
- this.state = {
135
- activeTab: 1,
136
- sortIndex: 0
137
- };
138
- }
139
-
140
- render() {
141
- return _react2.default.createElement(
142
- 'div',
143
- { id: 'anchorage-repair' },
144
- _react2.default.createElement('link', { rel: 'stylesheet', href: (0, _path.join)(__dirname, 'assets', 'style.css') }),
145
- _react2.default.createElement(
146
- _reactBootstrap.Tabs,
147
- { activeKey: this.state.activeTab, onSelect: this.handleSelectTab, id: 'anchorage-tabs' },
148
- _lodash2.default.map(this.props.fleets, (fleet, index) => _react2.default.createElement(
149
- _reactBootstrap.Tab,
150
- {
151
- eventKey: fleet.api_id,
152
- title: fleet.api_id,
153
- key: `anchorage-tab-${index}`,
154
- tabClassName: fleet.canRepair ? 'can-repair' : ''
155
- },
156
- _react2.default.createElement(_fleetList2.default, { fleet: fleet })
157
- )),
158
- _react2.default.createElement(
159
- _reactBootstrap.Tab,
160
- {
161
- className: 'candidate-pane',
162
- eventKey: -1,
163
- title: __('Candidates')
164
- },
165
- _react2.default.createElement(_candidates2.default, { handleSort: this.handleSort, sortIndex: this.state.sortIndex })
166
- )
167
- )
168
- );
169
- }
170
- }
171
-
172
- /*
173
-
174
- The following APIs are called in order when a fleet returns from expedition:
175
-
176
- - api_req_mission/result
177
- - api_port/port
178
-
179
- As anchorage repair pops up conditionally on the latter one,
180
- it also prevents other plugins' auto-switch mechanism on
181
- tracking api_req_mission/result calls.
182
-
183
- The problem is solved by applying a lock upon expedition returns
184
- and ignoring the immediately followed api_port/port call.
185
-
186
- */
187
- );let expedReturnLock = null;
188
- const clearExpedReturnLock = () => {
189
- if (expedReturnLock !== null) {
190
- clearTimeout(expedReturnLock);
191
- expedReturnLock = null;
192
- }
193
- };
194
-
195
- const switchPluginPath = exports.switchPluginPath = [{
196
- path: '/kcsapi/api_port/port',
197
- valid: () => {
198
- if (expedReturnLock !== null) {
199
- /*
200
- this is the immediately followed api_port/port call
201
- after an expedition returning event.
202
- */
203
- clearExpedReturnLock();
204
- return false;
205
- }
206
-
207
- const { fleets = [], ships = {}, equips = {}, repairs = [] } = getStore('info') || {};
208
- const $ships = getStore('const.$ships');
209
- const repairId = repairs.map(dock => dock.api_ship_id);
210
-
211
- const result = fleets.map(fleet => fleetAkashiConv(fleet, $ships, ships, equips, repairId));
212
- return result.some(fleet => fleet.canRepair && fleet.repairDetail.some(ship => ship.estimate > 0));
213
- }
214
- }, {
215
- path: '/kcsapi/api_req_mission/result',
216
- valid: () => {
217
- clearExpedReturnLock();
218
- expedReturnLock = setTimeout(clearExpedReturnLock,
219
- /*
220
- allow a window of 5 secnds before the lock
221
- clears itself
222
- */
223
- 5000);
224
- return false;
225
- }
226
- }];
@@ -1,226 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.switchPluginPath = exports.reactClass = undefined;
7
-
8
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
9
-
10
- // Import selectors defined in poi
11
-
12
-
13
- var _react = require('react');
14
-
15
- var _react2 = _interopRequireDefault(_react);
16
-
17
- var _reactRedux = require('react-redux');
18
-
19
- var _reselect = require('reselect');
20
-
21
- var _lodash = require('lodash');
22
-
23
- var _lodash2 = _interopRequireDefault(_lodash);
24
-
25
- var _path = require('path');
26
-
27
- var _reactBootstrap = require('react-bootstrap');
28
-
29
- var _selectors = require('views/utils/selectors');
30
-
31
- var _functions = require('./parts/functions');
32
-
33
- var _fleetList = require('./parts/fleet-list');
34
-
35
- var _fleetList2 = _interopRequireDefault(_fleetList);
36
-
37
- var _candidates = require('./parts/candidates');
38
-
39
- var _candidates2 = _interopRequireDefault(_candidates);
40
-
41
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42
-
43
- const { i18n, getStore } = window;
44
- const __ = i18n['poi-plugin-anchorage-repair'].__.bind(i18n['poi-plugin-anchorage-repair']);
45
-
46
- const AKASHI_ID = [182, 187]; // akashi and kai ID in $ships
47
- const SRF_ID = 86; // Ship Repair Facility ID in $slotitems
48
-
49
-
50
- // check a fleet status, returns information related to anchorage repair
51
- const fleetAkashiConv = (fleet, $ships, ships, equips, repairId) => {
52
- const pickKey = ['api_id', 'api_ship_id', 'api_lv', 'api_nowhp', 'api_maxhp', 'api_ndock_time'];
53
-
54
- let canRepair = false;
55
- let akashiFlagship = false;
56
- let repairCount = 0;
57
- const inExpedition = _lodash2.default.get(fleet, 'api_mission.0') && true;
58
- const flagShipInRepair = _lodash2.default.includes(repairId, _lodash2.default.get(fleet, 'api_ship.0', -1));
59
- const flagship = ships[_lodash2.default.get(fleet, 'api_ship.0', -1)];
60
-
61
- if (flagship != null) {
62
- akashiFlagship = _lodash2.default.includes(AKASHI_ID, flagship.api_ship_id);
63
- repairCount = _lodash2.default.filter(flagship.api_slot, item => _lodash2.default.get(equips, `${item}.api_slotitem_id`, -1) === SRF_ID).length;
64
- repairCount += akashiFlagship ? 2 : 0;
65
- }
66
-
67
- canRepair = akashiFlagship && !inExpedition && !flagShipInRepair;
68
-
69
- const repairDetail = _lodash2.default.map(_lodash2.default.filter(fleet.api_ship, shipId => shipId > 0), (shipId, index) => {
70
- if (shipId === -1) return false; // break, LODASH ONLY
71
-
72
- const ship = _lodash2.default.pick(ships[shipId], pickKey);
73
-
74
- const constShip = _lodash2.default.pick($ships[ship.api_ship_id], ['api_name', 'api_stype']);
75
-
76
- return _extends({}, ship, constShip, {
77
- estimate: (0, _functions.akashiEstimate)(ship),
78
- timePerHP: (0, _functions.getTimePerHP)(ship.api_lv, constShip.api_stype),
79
- inRepair: _lodash2.default.includes(repairId, ship.api_id),
80
- availableSRF: index < repairCount
81
- });
82
- });
83
-
84
- var repairStatus = 0
85
- if(canRepair){
86
- repairStatus = 1;
87
- }else{
88
- var flagshipid = _lodash2.default.get(fleet, 'api_ship.0', -1)
89
- var secondshipid = _lodash2.default.get(fleet, 'api_ship.0', -1)
90
- if(flagshipid==996||flagshipid==1002||secondshipid==996||secondshipid==1002){
91
- repairStatus = 2;
92
- }
93
- }
94
-
95
- return {
96
- api_id: fleet.api_id || -1,
97
- shipId: fleet.api_ship || [],
98
- canRepair,
99
- akashiFlagship,
100
- inExpedition,
101
- flagShipInRepair,
102
- repairCount,
103
- repairDetail
104
- };
105
- };
106
-
107
- // selectors
108
-
109
- const repairIdSelector = (0, _reselect.createSelector)([_selectors.repairsSelector], repair => _lodash2.default.map(repair, dock => dock.api_ship_id));
110
-
111
- const constShipsSelector = state => state.const.$ships || {};
112
-
113
- const fleetsAkashiSelector = (0, _reselect.createSelector)([constShipsSelector, _selectors.fleetsSelector, _selectors.shipsSelector, _selectors.equipsSelector, repairIdSelector], ($ships, fleets, ships, equips, repairId) => ({ fleets: _lodash2.default.map(fleets, fleet => fleetAkashiConv(fleet, $ships, ships, equips, repairId)) })
114
-
115
- // React
116
-
117
- );const reactClass = exports.reactClass = (0, _reactRedux.connect)((0, _selectors.createDeepCompareArraySelector)([fleetsAkashiSelector, _selectors.miscSelector], (data, { canNotify }) => _extends({}, data, {
118
- canNotify
119
- })))(class PluginAnchorageRepair extends _react.Component {
120
-
121
- constructor(props) {
122
- super(props);
123
-
124
- this.handleSelectTab = key => {
125
- this.setState({ activeTab: key });
126
- };
127
-
128
- this.handleSort = index => () => {
129
- this.setState({
130
- sortIndex: index
131
- });
132
- };
133
-
134
- this.state = {
135
- activeTab: 1,
136
- sortIndex: 0
137
- };
138
- }
139
-
140
- render() {
141
- return _react2.default.createElement(
142
- 'div',
143
- { id: 'anchorage-repair' },
144
- _react2.default.createElement('link', { rel: 'stylesheet', href: (0, _path.join)(__dirname, 'assets', 'style.css') }),
145
- _react2.default.createElement(
146
- _reactBootstrap.Tabs,
147
- { activeKey: this.state.activeTab, onSelect: this.handleSelectTab, id: 'anchorage-tabs' },
148
- _lodash2.default.map(this.props.fleets, (fleet, index) => _react2.default.createElement(
149
- _reactBootstrap.Tab,
150
- {
151
- eventKey: fleet.api_id,
152
- title: fleet.api_id,
153
- key: `anchorage-tab-${index}`,
154
- tabClassName: fleet.canRepair ? 'can-repair' : ''
155
- },
156
- _react2.default.createElement(_fleetList2.default, { fleet: fleet })
157
- )),
158
- _react2.default.createElement(
159
- _reactBootstrap.Tab,
160
- {
161
- className: 'candidate-pane',
162
- eventKey: -1,
163
- title: __('Candidates')
164
- },
165
- _react2.default.createElement(_candidates2.default, { handleSort: this.handleSort, sortIndex: this.state.sortIndex })
166
- )
167
- )
168
- );
169
- }
170
- }
171
-
172
- /*
173
-
174
- The following APIs are called in order when a fleet returns from expedition:
175
-
176
- - api_req_mission/result
177
- - api_port/port
178
-
179
- As anchorage repair pops up conditionally on the latter one,
180
- it also prevents other plugins' auto-switch mechanism on
181
- tracking api_req_mission/result calls.
182
-
183
- The problem is solved by applying a lock upon expedition returns
184
- and ignoring the immediately followed api_port/port call.
185
-
186
- */
187
- );let expedReturnLock = null;
188
- const clearExpedReturnLock = () => {
189
- if (expedReturnLock !== null) {
190
- clearTimeout(expedReturnLock);
191
- expedReturnLock = null;
192
- }
193
- };
194
-
195
- const switchPluginPath = exports.switchPluginPath = [{
196
- path: '/kcsapi/api_port/port',
197
- valid: () => {
198
- if (expedReturnLock !== null) {
199
- /*
200
- this is the immediately followed api_port/port call
201
- after an expedition returning event.
202
- */
203
- clearExpedReturnLock();
204
- return false;
205
- }
206
-
207
- const { fleets = [], ships = {}, equips = {}, repairs = [] } = getStore('info') || {};
208
- const $ships = getStore('const.$ships');
209
- const repairId = repairs.map(dock => dock.api_ship_id);
210
-
211
- const result = fleets.map(fleet => fleetAkashiConv(fleet, $ships, ships, equips, repairId));
212
- return result.some(fleet => fleet.canRepair && fleet.repairDetail.some(ship => ship.estimate > 0));
213
- }
214
- }, {
215
- path: '/kcsapi/api_req_mission/result',
216
- valid: () => {
217
- clearExpedReturnLock();
218
- expedReturnLock = setTimeout(clearExpedReturnLock,
219
- /*
220
- allow a window of 5 secnds before the lock
221
- clears itself
222
- */
223
- 5000);
224
- return false;
225
- }
226
- }];