@pisell/private-materials 6.11.183 → 6.11.184
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/plus/walletPassGallery/components/timelineSection/index.js +65 -3
- package/lib/plus/walletPassGallery/components/timelineSection/index.js +65 -0
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import React, { useMemo, useCallback } from 'react';
|
|
7
|
+
import React, { useMemo, useCallback, useEffect, useRef } from 'react';
|
|
8
8
|
import { useRequest } from 'ahooks';
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
10
|
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
@@ -16,6 +16,14 @@ import "./index.less";
|
|
|
16
16
|
dayjs.extend(timezonePlugin);
|
|
17
17
|
dayjs.extend(utcPlugin);
|
|
18
18
|
var stateTimeUnix = 1723255863; // 2024.8.10 时间戳
|
|
19
|
+
var POLL_INTERVAL = 2000;
|
|
20
|
+
var POLL_MAX_TIMES = 5;
|
|
21
|
+
var BALANCE_EPSILON = 1e-6;
|
|
22
|
+
var parseBalanceValue = function parseBalanceValue(value) {
|
|
23
|
+
if (value == null || value === '') return null;
|
|
24
|
+
var parsed = Number(value);
|
|
25
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
26
|
+
};
|
|
19
27
|
var TimelineSection = function TimelineSection(props) {
|
|
20
28
|
var code = props.code,
|
|
21
29
|
tag = props.tag,
|
|
@@ -40,6 +48,10 @@ var TimelineSection = function TimelineSection(props) {
|
|
|
40
48
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
41
49
|
timeLineDetail = _React$useState6[0],
|
|
42
50
|
setTimeLineDetail = _React$useState6[1];
|
|
51
|
+
var pollTimerRef = useRef(null);
|
|
52
|
+
var pollCountRef = useRef(0);
|
|
53
|
+
var isPollingRef = useRef(false);
|
|
54
|
+
var exhaustedBalanceRef = useRef(null);
|
|
43
55
|
var assetActionEnum = useMemo(function () {
|
|
44
56
|
return {
|
|
45
57
|
recharge: tag === 'point_card' ? locales.getText('wallet-pass-gallery.pointsEarned') : locales.getText('wallet-pass-gallery.recharge'),
|
|
@@ -109,9 +121,59 @@ var TimelineSection = function TimelineSection(props) {
|
|
|
109
121
|
ready: !!code,
|
|
110
122
|
refreshDeps: [code, tag, balance, expireDate]
|
|
111
123
|
});
|
|
124
|
+
var outerBalanceNumber = useMemo(function () {
|
|
125
|
+
return parseBalanceValue(balance);
|
|
126
|
+
}, [balance]);
|
|
127
|
+
var timelineBalanceNumber = useMemo(function () {
|
|
128
|
+
var _assetListReq$data, _parseBalanceValue;
|
|
129
|
+
var firstItem = (_assetListReq$data = assetListReq.data) === null || _assetListReq$data === void 0 || (_assetListReq$data = _assetListReq$data.list) === null || _assetListReq$data === void 0 ? void 0 : _assetListReq$data[0];
|
|
130
|
+
if (!firstItem) return 0;
|
|
131
|
+
return (_parseBalanceValue = parseBalanceValue(firstItem.balance)) !== null && _parseBalanceValue !== void 0 ? _parseBalanceValue : 0;
|
|
132
|
+
}, [assetListReq.data]);
|
|
133
|
+
var stopPolling = useCallback(function () {
|
|
134
|
+
if (pollTimerRef.current) {
|
|
135
|
+
clearTimeout(pollTimerRef.current);
|
|
136
|
+
pollTimerRef.current = null;
|
|
137
|
+
}
|
|
138
|
+
isPollingRef.current = false;
|
|
139
|
+
pollCountRef.current = 0;
|
|
140
|
+
}, []);
|
|
141
|
+
var scheduleNextPolling = useCallback(function () {
|
|
142
|
+
if (!isPollingRef.current) return;
|
|
143
|
+
if (pollCountRef.current >= POLL_MAX_TIMES) {
|
|
144
|
+
exhaustedBalanceRef.current = outerBalanceNumber;
|
|
145
|
+
stopPolling();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
pollTimerRef.current = setTimeout(function () {
|
|
149
|
+
if (!isPollingRef.current) return;
|
|
150
|
+
pollCountRef.current += 1;
|
|
151
|
+
assetListReq.refresh();
|
|
152
|
+
scheduleNextPolling();
|
|
153
|
+
}, POLL_INTERVAL);
|
|
154
|
+
}, [assetListReq, outerBalanceNumber, stopPolling]);
|
|
155
|
+
useEffect(function () {
|
|
156
|
+
var isMatch = outerBalanceNumber !== null && Math.abs(outerBalanceNumber - timelineBalanceNumber) < BALANCE_EPSILON;
|
|
157
|
+
if (isMatch) {
|
|
158
|
+
exhaustedBalanceRef.current = null;
|
|
159
|
+
stopPolling();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
var shouldStartPolling = outerBalanceNumber !== null && !isPollingRef.current && (exhaustedBalanceRef.current === null || Math.abs(exhaustedBalanceRef.current - outerBalanceNumber) >= BALANCE_EPSILON);
|
|
163
|
+
if (shouldStartPolling) {
|
|
164
|
+
isPollingRef.current = true;
|
|
165
|
+
pollCountRef.current = 0;
|
|
166
|
+
scheduleNextPolling();
|
|
167
|
+
}
|
|
168
|
+
}, [outerBalanceNumber, timelineBalanceNumber, scheduleNextPolling, stopPolling]);
|
|
169
|
+
useEffect(function () {
|
|
170
|
+
return function () {
|
|
171
|
+
stopPolling();
|
|
172
|
+
};
|
|
173
|
+
}, [stopPolling]);
|
|
112
174
|
var timelineItems = useMemo(function () {
|
|
113
|
-
var _assetListReq$
|
|
114
|
-
var list = ((_assetListReq$
|
|
175
|
+
var _assetListReq$data2;
|
|
176
|
+
var list = ((_assetListReq$data2 = assetListReq.data) === null || _assetListReq$data2 === void 0 ? void 0 : _assetListReq$data2.list) || [];
|
|
115
177
|
if (!Array.isArray(list) || list.length === 0) return [];
|
|
116
178
|
var filteredByAction = list.filter(function (item) {
|
|
117
179
|
return !!assetActionEnum[item.action || ''];
|
|
@@ -44,6 +44,14 @@ var import_index = require("./index.less");
|
|
|
44
44
|
import_dayjs.default.extend(import_timezone.default);
|
|
45
45
|
import_dayjs.default.extend(import_utc.default);
|
|
46
46
|
var stateTimeUnix = 1723255863;
|
|
47
|
+
var POLL_INTERVAL = 2e3;
|
|
48
|
+
var POLL_MAX_TIMES = 5;
|
|
49
|
+
var BALANCE_EPSILON = 1e-6;
|
|
50
|
+
var parseBalanceValue = (value) => {
|
|
51
|
+
if (value == null || value === "") return null;
|
|
52
|
+
const parsed = Number(value);
|
|
53
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
54
|
+
};
|
|
47
55
|
var TimelineSection = (props) => {
|
|
48
56
|
const {
|
|
49
57
|
code,
|
|
@@ -61,6 +69,10 @@ var TimelineSection = (props) => {
|
|
|
61
69
|
const [timeLineDetail, setTimeLineDetail] = import_react.default.useState(
|
|
62
70
|
null
|
|
63
71
|
);
|
|
72
|
+
const pollTimerRef = (0, import_react.useRef)(null);
|
|
73
|
+
const pollCountRef = (0, import_react.useRef)(0);
|
|
74
|
+
const isPollingRef = (0, import_react.useRef)(false);
|
|
75
|
+
const exhaustedBalanceRef = (0, import_react.useRef)(null);
|
|
64
76
|
const assetActionEnum = (0, import_react.useMemo)(() => {
|
|
65
77
|
return {
|
|
66
78
|
recharge: tag === "point_card" ? import_utils.locales.getText("wallet-pass-gallery.pointsEarned") : import_utils.locales.getText("wallet-pass-gallery.recharge"),
|
|
@@ -138,6 +150,59 @@ var TimelineSection = (props) => {
|
|
|
138
150
|
refreshDeps: [code, tag, balance, expireDate]
|
|
139
151
|
}
|
|
140
152
|
);
|
|
153
|
+
const outerBalanceNumber = (0, import_react.useMemo)(() => parseBalanceValue(balance), [balance]);
|
|
154
|
+
const timelineBalanceNumber = (0, import_react.useMemo)(() => {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
const firstItem = (_b = (_a = assetListReq.data) == null ? void 0 : _a.list) == null ? void 0 : _b[0];
|
|
157
|
+
if (!firstItem) return 0;
|
|
158
|
+
return parseBalanceValue(firstItem.balance) ?? 0;
|
|
159
|
+
}, [assetListReq.data]);
|
|
160
|
+
const stopPolling = (0, import_react.useCallback)(() => {
|
|
161
|
+
if (pollTimerRef.current) {
|
|
162
|
+
clearTimeout(pollTimerRef.current);
|
|
163
|
+
pollTimerRef.current = null;
|
|
164
|
+
}
|
|
165
|
+
isPollingRef.current = false;
|
|
166
|
+
pollCountRef.current = 0;
|
|
167
|
+
}, []);
|
|
168
|
+
const scheduleNextPolling = (0, import_react.useCallback)(() => {
|
|
169
|
+
if (!isPollingRef.current) return;
|
|
170
|
+
if (pollCountRef.current >= POLL_MAX_TIMES) {
|
|
171
|
+
exhaustedBalanceRef.current = outerBalanceNumber;
|
|
172
|
+
stopPolling();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
pollTimerRef.current = setTimeout(() => {
|
|
176
|
+
if (!isPollingRef.current) return;
|
|
177
|
+
pollCountRef.current += 1;
|
|
178
|
+
assetListReq.refresh();
|
|
179
|
+
scheduleNextPolling();
|
|
180
|
+
}, POLL_INTERVAL);
|
|
181
|
+
}, [assetListReq, outerBalanceNumber, stopPolling]);
|
|
182
|
+
(0, import_react.useEffect)(() => {
|
|
183
|
+
const isMatch = outerBalanceNumber !== null && Math.abs(outerBalanceNumber - timelineBalanceNumber) < BALANCE_EPSILON;
|
|
184
|
+
if (isMatch) {
|
|
185
|
+
exhaustedBalanceRef.current = null;
|
|
186
|
+
stopPolling();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const shouldStartPolling = outerBalanceNumber !== null && !isPollingRef.current && (exhaustedBalanceRef.current === null || Math.abs(exhaustedBalanceRef.current - outerBalanceNumber) >= BALANCE_EPSILON);
|
|
190
|
+
if (shouldStartPolling) {
|
|
191
|
+
isPollingRef.current = true;
|
|
192
|
+
pollCountRef.current = 0;
|
|
193
|
+
scheduleNextPolling();
|
|
194
|
+
}
|
|
195
|
+
}, [
|
|
196
|
+
outerBalanceNumber,
|
|
197
|
+
timelineBalanceNumber,
|
|
198
|
+
scheduleNextPolling,
|
|
199
|
+
stopPolling
|
|
200
|
+
]);
|
|
201
|
+
(0, import_react.useEffect)(() => {
|
|
202
|
+
return () => {
|
|
203
|
+
stopPolling();
|
|
204
|
+
};
|
|
205
|
+
}, [stopPolling]);
|
|
141
206
|
const timelineItems = (0, import_react.useMemo)(() => {
|
|
142
207
|
var _a;
|
|
143
208
|
const list = ((_a = assetListReq.data) == null ? void 0 : _a.list) || [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.11.
|
|
3
|
+
"version": "6.11.184",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"react-infinite-scroll-component": "^6.1.0",
|
|
68
68
|
"react-resizable": "^3.0.5",
|
|
69
69
|
"styled-components": "^6.0.0-rc.3",
|
|
70
|
-
"@pisell/utils": "3.0.2",
|
|
71
70
|
"@pisell/materials": "6.11.57",
|
|
72
71
|
"@pisell/date-picker": "3.0.8",
|
|
72
|
+
"@pisell/utils": "3.0.2",
|
|
73
73
|
"@pisell/icon": "0.0.11"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|