fix: persist deselected account state across chain switches (OK-51089)#10552
fix: persist deselected account state across chain switches (OK-51089)#10552PatrickChoo wants to merge 1 commit intoOneKeyHQ:xfrom
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
285aece to
908fa72
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
1 similar comment
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
1 similar comment
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
e7f4e12 to
ec027e3
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
ec027e3 to
fe1556e
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
1 similar comment
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
5678e12 to
b814804
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
1 similar comment
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
754683c to
3abb947
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
8c07fef to
a6bd976
Compare
Cache deselection state per network+deriveType so switching chains preserves selections without risking stale account deletion.
a6bd976 to
887480f
Compare
There was a problem hiding this comment.
🔴 Stale closure in headerRight causes saveDeselectionToCache to save outdated deselection state on derive type switch
saveDeselectionToCache (line 340) closes over deselectedExistingIndexes state and is listed in its useCallback deps (line 350). However, headerRight's useCallback (line 519) does NOT include saveDeselectionToCache in its dependency array (lines 610-619). When a user deselects accounts and then switches derive type, the onChange handler at line 562 calls a stale saveDeselectionToCache that captured the old (empty) deselectedExistingIndexes — the user's deselections are silently lost and cannot be restored when switching back. This directly breaks the PR's intended feature of persisting deselection state across derive type switches.
Triggering flow
- User is on networkA with deriveTypeA,
headerRightis created. - User deselects some existing accounts →
deselectedExistingIndexesupdates →saveDeselectionToCacheis recreated. headerRightis NOT recreated becausesaveDeselectionToCacheis not in its dependency array.- User switches to deriveTypeB →
onChangefires with the stalesaveDeselectionToCachefrom step 1. - Stale
saveDeselectionToCachesaves{}(empty) to cache keynetworkA__deriveTypeA. - User switches back to deriveTypeA → empty state is restored, deselections are gone.
(Refers to lines 610-619)
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Closing: PR had too many unrelated changes mixed in. Reopening as a clean PR with only the OK-51089 fix. |
Summary
deselectedExistingIndexeswas reset on network/deriveType change whilenormalSelectedIndexes(add selections) was preservedTest plan
Jira: OK-51089