fix: 回前台重连去抖,避免一次切前台触发两轮同步 - #242
Open
CorrectRoadH wants to merge 1 commit into
Open
Conversation
手机回到前台时 focus 和 visibilitychange 会各调一次 triggerReconnect, 每次重连成功都会发起一轮全库扫描同步。 合并为 1s 去抖,且只在连接确实已断开时才重连。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T2QYrNjmd1hNqgzWyR4jFZ
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.
问题
手机回到前台时,
onWindowFocus和onVisibilityChange会各调一次triggerReconnect()。而每次重连成功(auth →StartHandle)都会无条件发起一轮同步,也就是一次全库扫描。修复
把两个入口合并到
scheduleResumeReconnect():1s 去抖,且只在!isConnected()时才真的重连。一次切前台 = 一次重连 = 一轮同步。定时器在stop()里一并清理。已跑
tsc -noEmit -skipLibCheck通过。🤖 Generated with Claude Code
https://claude.ai/code/session_01T2QYrNjmd1hNqgzWyR4jFZ