-
Notifications
You must be signed in to change notification settings - Fork 210
ScriptList Fix #547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScriptList Fix #547
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the favicon loading issue in ScriptList
by refactoring batch processing of script favicons, removing unused utilities, and extracting avatar/tooltip render logic into memoized components for performance.
- Refactored
processScriptFavicon
to use async/await and batch updates viarequestAnimationFrame
- Removed unused
chunkArray
andscriptListSort
functions - Introduced memoized components (
MemoizedAvatar
,FavoriteAvatars
,RunApplyTooltip
,RunApplyGroup
) inScriptList.tsx
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/pages/store/utils.ts | Refactored favicon processing, removed chunkArray , added FavIconResult type, updated batching |
src/pages/options/routes/utils.tsx | Removed unused scriptListSort and related DAO import |
src/pages/options/routes/ScriptList.tsx | Extracted avatar/tooltip logic into memoized components and simplified render function |
processScriptFavicon(script).then((result: FavIconResult) => { | ||
results.push(result); | ||
// 下一个 MacroTask 执行。 | ||
// 使用 requestAnimationFrame 而非setTimeout 是因为前台才要显示。而且网页绘画中时会延后这个 | ||
if (!waiting) { | ||
requestAnimationFrame(() => { | ||
waiting = false; | ||
if (!results.length) return; | ||
const chunkResults: FavIconResult[] = results.slice(0); | ||
results.length = 0; | ||
store.dispatch(scriptSlice.actions.setScriptFavicon(chunkResults)); | ||
}); | ||
waiting = true; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The promise from processScriptFavicon
has no error handler. Add a .catch()
to handle potential rejections and avoid unhandled promise errors.
processScriptFavicon(script).then((result: FavIconResult) => { | |
results.push(result); | |
// 下一个 MacroTask 执行。 | |
// 使用 requestAnimationFrame 而非setTimeout 是因为前台才要显示。而且网页绘画中时会延后这个 | |
if (!waiting) { | |
requestAnimationFrame(() => { | |
waiting = false; | |
if (!results.length) return; | |
const chunkResults: FavIconResult[] = results.slice(0); | |
results.length = 0; | |
store.dispatch(scriptSlice.actions.setScriptFavicon(chunkResults)); | |
}); | |
waiting = true; | |
} | |
}); | |
processScriptFavicon(script) | |
.then((result: FavIconResult) => { | |
results.push(result); | |
// 下一个 MacroTask 执行。 | |
// 使用 requestAnimationFrame 而非setTimeout 是因为前台才要显示。而且网页绘画中时会延后这个 | |
if (!waiting) { | |
requestAnimationFrame(() => { | |
waiting = false; | |
if (!results.length) return; | |
const chunkResults: FavIconResult[] = results.slice(0); | |
results.length = 0; | |
store.dispatch(scriptSlice.actions.setScriptFavicon(chunkResults)); | |
}); | |
waiting = true; | |
} | |
}) | |
.catch((error) => { | |
console.error("Failed to process script favicon:", error); | |
// Optionally, handle the error further (e.g., dispatch an error action) | |
}); |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该不用加。看你意思
}[]; | ||
}) => { | ||
const processed = useMemo(() => { | ||
// 排序并且只显示前5个 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment mentions showing the first 5 items, but the code slices only 4 (.slice(0, 4)
). Update the comment or slice range for consistency.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对喔。为什麼是5个
应该是4个吧?
这个注䆁一直都是错了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是错了,4个没问题
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
先不要合拼。Sorting那個功能有點問題。我再改一下 |
dc35ec8
to
26c0569
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #547 +/- ##
=======================================
Coverage ? 18.29%
=======================================
Files ? 200
Lines ? 21655
Branches ? 895
=======================================
Hits ? 3961
Misses ? 17604
Partials ? 90 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3d8a8d0
to
8fb3cc6
Compare
原本的奇怪 drag anchor 寫法有問題 這個PR將會改用官方的 https://arco.design/react/components/table#%E6%8B%96%E6%8B%BD%E9%94%9A%E7%82%B9%E6%8E%92%E5%BA%8F |
确实官方的例子看起来更好,我也不太记得为什么为什么用这么麻烦的东西了,可能那时候是这个示例 |
React的坑很難搞。先關掉PR。日後修改好再提交 |
@cyfung1031 是遇到啥了吗?休息下吧😄,我也得着手点其它工作了 |
关于这个图标问题,我觉得可能在安装脚本时,就储存起来,不再从网络读取这样可能会比较好 |
问题是元件他会重刷之类 对了 其实官方有拖拉调阔度呀 (个人不喜欢React。太笨了。不用SolidJS也用VueJS3吧) |
官方拉阔度 这样就不用搞什麼 newColumn 跟 Input 啦 |
@cyfung1031 我记得没有使用这个也是有原因的,好像是因为想实现隐藏和自动 我倒是挺喜欢React的,最开始我使用的vue😄 |
終於解決了 圖標載入問題