Repository navigation
fix(changelog): 更新提示改为用户在可见页面上看到才算已读 —— 页面可见才申请显示权,显示权经长连接占住、看完或卸载即释放,关闭弹窗或持续可见 3 秒才写已读;首装标记改写本地存储,只挡本机(#1172) - #1173
Merged
Conversation
…,关闭弹窗或持续可见 3 秒才写已读;首装标记改写本地存储,只挡本机(#1172)
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 #1172
问题
有用户反馈升级后从没见过更新提示。后台把显示权发给第一个来问的页面时当场标记已读,而那个页面用户未必看得到:浏览器重启后恢复的后台标签页、Ctrl/⌘ 点击打开的后台标签页、预渲染页面、马上跳走的中转页都会先抢到,这个上架版本的提示就永久丢了。首装标记写在同步存储里,用户在另一台设备新装同一版本也会挡住这台设备的提示。
修复
src/changelog/prompt.ts(新):content script 侧的更新提示流程。本地预筛 → 页面可见才申请显示权 → 渲染 → 用户关闭弹窗或弹窗持续可见满 3 秒才写已读,再交还显示权;还没算看过就切走则收起弹窗、交还显示权,切回来或下一个可见页面再弹;别的页面占着时每秒再问一次。content script 失效时收起还没算看过的弹窗。src/changelog/claim.ts:显示权改为“占住”,申请结果分granted/seen/busy,新增releaseShow;不再当场写已读。首装内存闸门保留。src/changelog/state.ts:首装标记改写本地存储(markInstalled),只挡本机;去掉clearSeen。src/changelog/modal.ts:showChangelog接收关闭回调,返回不触发回调的收起函数。entrypoints/content.ts:可见性取自visibilityState与document.prerendering;显示权经长连接pt-changelog-claim申请,占着期间每 20 秒发心跳防 SW 闲置回收。entrypoints/background.ts:onConnect以端口为占用者,断开即释放;排队期间断开的端口拿到显示权后立即交还。首装改调markInstalled。验证
prompt.test.ts(17 条,接真实仲裁与已读存储):后台标签页切到前台才弹、恢复一批标签页只在前台弹、后台标签页没看就关不消耗提示、弹出后马上卸载或切走不记已读且下一个页面再弹、切走再切回重弹、看过后切走弹窗留着、多个可见页面只弹一个、占用者离开后等待的页面接着弹、渲染失败交还显示权、失效时收起弹窗、首装标记挡住本机。claim.test.ts、state.test.ts;变异检查:改回“发放即标记已读”时 6 条流程用例变红。pnpm typecheck、pnpm test(215 个文件、2619 条)、pnpm build通过。