refactor: 引入 SWR 统一钱包余额查询与轮询逻辑
This commit is contained in:
@@ -66,11 +66,13 @@ export function WalletScreen() {
|
||||
setLogsLoading(true);
|
||||
}
|
||||
try {
|
||||
const b = await getWalletBalance({ currency });
|
||||
// 并行请求余额和日志,避免瀑布式串行等待
|
||||
const [b, nextLogs] = await Promise.all([
|
||||
getWalletBalance({ currency }),
|
||||
loadLogs(1, false),
|
||||
]);
|
||||
if (cancelled) return;
|
||||
setBalance(b);
|
||||
const nextLogs = await loadLogs(1, false);
|
||||
if (cancelled) return;
|
||||
setLogs(nextLogs);
|
||||
} catch (e) {
|
||||
if (!cancelled) {
|
||||
@@ -93,9 +95,12 @@ export function WalletScreen() {
|
||||
setError(null);
|
||||
setLogsLoading(true);
|
||||
try {
|
||||
const b = await getWalletBalance({ currency });
|
||||
// 并行请求余额和日志
|
||||
const [b] = await Promise.all([
|
||||
getWalletBalance({ currency }),
|
||||
loadLogs(1, false),
|
||||
]);
|
||||
setBalance(b);
|
||||
await loadLogs(1, false);
|
||||
} catch (e) {
|
||||
setError(formatWalletClientError(e, t));
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user