fix(userInfo): 刷新失败时保留上次成功刷新的数值字段 - #1422
Open
fnyfree wants to merge 1 commit into
Open
Conversation
站点用户信息刷新失败(Cloudflare 拦截、需要登录、解析错误等)时, 返回的最小错误对象会整体覆盖 metadata.lastUserInfo,导致 MyData 表格中上次成功获取的数值(上传量、下载量、魔力值等)消失。 现当新数据 status 非成功且上次数据为成功时,将错误对象合并到 上次数据之上(错误对象中的 status/updateAt 及部分解析成功的 新鲜字段优先覆盖),表格保留最后已知值并显示错误状态徽章。 历史存储(userInfo)仍仅在成功时写入,趋势图与统计不受影响。 Closes pt-plugins#769
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds fallback merging logic when persisting user info so that on refresh failures the last successful numeric fields are preserved while error status and fresh fields still update. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Pull request overview
本 PR 修复站点用户信息刷新失败时(如 Cloudflare 拦截、需要登录、解析错误)导致 metadata.lastUserInfo 被最小错误对象覆盖、从而使 MyData 表格“上次成功刷新”的关键数值字段(上传/下载/分享率/魔力值等)消失的问题(Closes #769)。修复点位于 offscreen 侧写入 lastUserInfo 的逻辑,通过在失败刷新时对“上次 success 的数据”进行合并回退,保留最后已知值并更新失败状态与时间戳。
Changes:
- 在
setSiteLastUserInfo中:当本次刷新status !== success且上次缓存为success时,将错误对象合并覆盖到上次成功数据之上,以保留数值字段。 - 引入
toMerged深合并工具用于合并“上次成功值 + 本次错误状态/新鲜字段”。
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #769
问题
站点用户信息刷新失败(Cloudflare 拦截、需要登录、解析错误等)时,
AbstractPrivateSite.getUserInfoResult返回仅含{status, updateAt, site}的最小错误对象,setSiteLastUserInfo将其整体覆盖metadata.lastUserInfo,导致 MyData 表格中上次成功获取的数值(上传量/下载量/分享率/魔力值等)消失(#769)。正如报告者所述,站点被 CF 临时拦截是暂时性的,「过些时间就好了,但这段时间是没数据的」。
修复
setSiteLastUserInfo中,当新数据status !== success且上次数据为success时,将错误对象深合并到上次数据之上:previous.status === success防止错误数据叠加效果:表格显示最后已知值 + 错误状态徽章(
<ResultParseStatus/>原有渲染,UI 零改动)。设计说明
getSiteUserInfoResult中已有同语义的回退逻辑(站点不可查询时从历史挑最近一次 success 数据,见 userInfo.ts 原第 62-79 行「以避免 metadata.lastUserInfo 为 undefined」),本 PR 将该「最后已知值」语义延伸到刷新失败场景userInfo)仍仅在成功时写入——向历史写入非当期实测值属于伪造数据;图表数据源不受本 PR 影响E2E 验证(Chrome for Testing + 实际构建扩展,5 场景)
校验
Summary by Sourcery
Bug Fixes: