perf(marketplace,localasr): 清理冗余定时器 (#674)

issue #470:
- Marketplace 上传后双重 setTimeout(1.5s+5s) 去重为单次 5s——乐观更新已即时反映「我的
  发布」,延时刷新仅做服务端状态校准,1.5s 那次纯冗余。
- LocalAsr scheduleScrollGuardRestore 三连 setTimeout(0/80/200ms) 仅删等价的 0ms 那枪
  (已被紧随的 rAF 覆盖),保留 80/200ms 兜住 rAF 之后的异步重排,避免滚动跳变回归。

Co-authored-by: 吕柏青 <lubaiqing9@gmail.com>
This commit is contained in:
TRIPand吕柏青 authored and GitHub committed 2026-06-16 10:56:32 +08:00
1 parent 9f3eebcb88
commit 16e0f27685
2 files changed
+5 -3

No files matched your search

+2 -1
View File
@@ -201,7 +201,8 @@ export function LocalAsr({ embedded = false }: LocalAsrProps = {}) {
}
const scheduleScrollGuardRestore = () => {
window.setTimeout(restoreScrollGuard, 0)
// issue #470:立即帧由下面的 rAF + 嵌套 rAF 覆盖(≈0~32ms),故移除等价的 setTimeout(…,0);
// 80ms / 200ms 两枪保留,用于兜住 rAF 之后才发生的异步重排(如图片晚加载)。
window.setTimeout(restoreScrollGuard, 80)
window.setTimeout(restoreScrollGuard, 200)
window.requestAnimationFrame(() => {
+3 -2
View File
@@ -386,8 +386,9 @@ export function Marketplace() {
setUploadOriginPackId(null);
setUploadTargetName(null);
setSelectedUploadPackId(null);
// 后续 polling 用服务端真实数据校准(审核状态可能 pending→approved/rejected)。
window.setTimeout(() => { void refresh(); void refreshMyPacks(); }, 1500);
// issue #470:上传后给后端一点时间落库 + 跑审核,再用服务端真实数据校准一次
// (审核状态可能 pending→approved/rejected)。乐观更新已即时反映「我的发布」,
// 这里只需单次兜底刷新;取较长延时(5s)确保后端最终一致后能查到,去掉冗余的 1.5s 那次。
window.setTimeout(() => { void refresh(); void refreshMyPacks(); }, 5000);
} catch (error) {
setActionMsg({ kind: 'err', text: t('marketplace.errors.upload', { err: errorMessage(error) }) });