@pisell/pisellos 0.10.52 → 0.10.53
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.
|
@@ -57,37 +57,42 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
57
57
|
key: "initialize",
|
|
58
58
|
value: function () {
|
|
59
59
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
60
|
+
var _options$initialState;
|
|
61
|
+
var initialScheduleList, hasInitialScheduleList;
|
|
60
62
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
61
63
|
while (1) switch (_context.prev = _context.next) {
|
|
62
64
|
case 0:
|
|
65
|
+
// The store proxies initialState, so capture its input before resets write through it.
|
|
66
|
+
initialScheduleList = (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.scheduleList;
|
|
67
|
+
hasInitialScheduleList = Array.isArray(initialScheduleList);
|
|
63
68
|
this.resetScheduleCatalog();
|
|
64
69
|
this.core = core;
|
|
65
70
|
|
|
66
71
|
// 获取依赖的插件
|
|
67
72
|
this.request = core.getPlugin('request');
|
|
68
73
|
if (this.request) {
|
|
69
|
-
_context.next =
|
|
74
|
+
_context.next = 7;
|
|
70
75
|
break;
|
|
71
76
|
}
|
|
72
77
|
throw new Error('ScheduleModule 需要 request 插件支持');
|
|
73
|
-
case
|
|
78
|
+
case 7:
|
|
74
79
|
// if (options?.initialState) {
|
|
75
80
|
// this.state = { ...this.state, ...options.initialState }
|
|
76
81
|
// }
|
|
77
82
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
78
83
|
this.updateOtherParams(options.otherParams || {});
|
|
79
84
|
if (options.initialState) {
|
|
80
|
-
this.store.scheduleList =
|
|
85
|
+
this.store.scheduleList = hasInitialScheduleList ? initialScheduleList : [];
|
|
81
86
|
this.syncScheduleMap();
|
|
82
87
|
this.store.availabilityDateList = options.initialState.availabilityDateList;
|
|
83
|
-
this.hasLoadedScheduleList =
|
|
88
|
+
this.hasLoadedScheduleList = hasInitialScheduleList;
|
|
84
89
|
} else {
|
|
85
90
|
this.store.scheduleList = [];
|
|
86
91
|
this.store.map = new Map();
|
|
87
92
|
this.store.availabilityDateList = [];
|
|
88
93
|
this.hasLoadedScheduleList = false;
|
|
89
94
|
}
|
|
90
|
-
case
|
|
95
|
+
case 10:
|
|
91
96
|
case "end":
|
|
92
97
|
return _context.stop();
|
|
93
98
|
}
|
|
@@ -32,6 +32,9 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
32
32
|
super(name, version);
|
|
33
33
|
}
|
|
34
34
|
async initialize(core, options) {
|
|
35
|
+
// The store proxies initialState, so capture its input before resets write through it.
|
|
36
|
+
const initialScheduleList = options.initialState?.scheduleList;
|
|
37
|
+
const hasInitialScheduleList = Array.isArray(initialScheduleList);
|
|
35
38
|
this.resetScheduleCatalog();
|
|
36
39
|
this.core = core;
|
|
37
40
|
|
|
@@ -47,10 +50,10 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
47
50
|
this.store = options?.store;
|
|
48
51
|
this.updateOtherParams(options.otherParams || {});
|
|
49
52
|
if (options.initialState) {
|
|
50
|
-
this.store.scheduleList =
|
|
53
|
+
this.store.scheduleList = hasInitialScheduleList ? initialScheduleList : [];
|
|
51
54
|
this.syncScheduleMap();
|
|
52
55
|
this.store.availabilityDateList = options.initialState.availabilityDateList;
|
|
53
|
-
this.hasLoadedScheduleList =
|
|
56
|
+
this.hasLoadedScheduleList = hasInitialScheduleList;
|
|
54
57
|
} else {
|
|
55
58
|
this.store.scheduleList = [];
|
|
56
59
|
this.store.map = new Map();
|