Skip to content

Fix kid mode state problem#2930

Merged
veloce merged 1 commit into
lichess-org:mainfrom
r3econ:refresh-account-after-activating-or-deactivating-kid-mode
Apr 9, 2026
Merged

Fix kid mode state problem#2930
veloce merged 1 commit into
lichess-org:mainfrom
r3econ:refresh-account-after-activating-or-deactivating-kid-mode

Conversation

@r3econ

@r3econ r3econ commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

This PR fixes the following problem:

After toggling kid mode in a browser and returning to the app, the UI still showed the stale state.

Root cause

launchUrl resolves immediately after handing the URL off to the OS — not when the user returns to the app. So accountProvider was being invalidated and re-fetched before the user had a chance to make any changes in the browser, leaving the UI with stale data on return.

Fix

Add a WidgetsBindingObserver to both the drawer and preferences screen states. When the user taps the kid mode tile, a _pendingKidModeRefresh flag is set. When the app lifecycle transitions back to resumed (i.e. the user returns from the browser), accountProvider is invalidated and the correct state is fetched.

Demo

Before
kid_mode_bug_before.mov
After
kid_mode_bug.mov

…n states

When the user taps the kid mode tile, a _pendingKidModeRefresh flag is set. When the app lifecycle transitions back to resumed (user returns from the browser), accountProvider is invalidated and the correct state is fetched.

@veloce veloce left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

@veloce veloce merged commit b472ee5 into lichess-org:main Apr 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants