fix(settings): reset shared controllers without notifying during a route build - #162
Conversation
The hub and every settings sub-page bind MagicStarterProfileController, and the hub stays mounted under a stacked sub-page. Each sub-page reset the controller in onInit with clearErrors() and setEmpty(), which notify, while its route was being built, so the hub was marked dirty mid-build and every opening reported "setState() or markNeedsBuild() called during build". The eight views sharing the controller now call resetQuietly(), which clears and empties it with notifications suppressed. Nothing needed the notification: the resetting view reads the state in its own first build and the hub renders nothing from it. Closes #161
…pressions Review follow-up. The sessions pages load on mount, and getSessions() sets loading before its first await, so opening Sessions still marked the hub dirty mid-build; the test missed it because the sessions feature defaults to off. Both session loads now run under withoutNotifying, and the test turns the feature on. Team create had the same shape over team settings, which opens it through the team selector, and now resets its controller quietly too. withoutNotifying cleared a flag, so the first of two overlapping actions to finish un-suppressed the other. It is a count now, and resetQuietly no longer touches it: it uses setState(notify: false).
|
Note Kodizm (AI-generated). May contain mistakes; verify before acting. The approach is sound and matches the described fix, but CI is red on this commit, so it isn't ready to merge until that is explained. MajorCI, Minor
TestsNew widget tests cover each of the 8 sub-pages over the hub and team create over settings. Controller unit tests cover the overlapping CI
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Note Kodizm (AI-generated). May contain mistakes; verify before acting. CI is now green; the earlier blocker is resolved. Since my last review, the only change is a pure The two minor points from my earlier review still apply and haven't been addressed or discussed since: Minor
TestsUnchanged from last review: new widget tests cover the 8 sub-pages over the hub and team create over settings; controller unit tests cover overlapping CI
|
|
Both minors addressed in 555793b.
@kodizm review |
|
Note Kodizm (AI-generated). May contain mistakes; verify before acting. Both prior minors are resolved; nothing outstanding. Verified directly: No new commits since the last round; this is the same 555793b head already reviewed. TestsUnchanged: widget tests cover the 8 sub-pages over the hub and team create over settings; controller unit tests cover overlapping CI
|
What
resetQuietly()onMagicStarterProfileControllerandMagicStarterTeamController: clears errors and returns to empty without notifying (setState(notify: false)).onInit, and the two that load sessions on mount do so underwithoutNotifying.withoutNotifying's suppression is a count instead of a flag, so overlapping actions no longer un-suppress each other.Why
onInitruns while the new route is being built. The settings hub and every sub-page bind one controller and the hub stays mounted under a stacked sub-page, so a notifying reset (andgetSessions()'s synchronoussetLoading()) marked the hub dirty mid-build: "setState() or markNeedsBuild() called during build" on every opening. Team create over team settings has the same shape. Closes #161.Testing
settings_hub_view_test.dart: each of 8 sub-pages pushed over the hub with stale errors set and the sessions feature on. All red before, green after; reverting one view or the sessions wrapper turns only its own case red.magic_starter_team_create_view_test.dart: create pushed over settings; red before, green after.withoutNotifyingstays quiet (red with the old flag),resetQuietlyclears without notifying.flutter analyzeclean, 1550 tests green.Not in this PR
Team settings pushed over team create (after a successful create) still notifies through
loadMembersAndInvitations()'s synchronoussetLoading(). Fixing it needs a choice between a quiet-start option on the method and a framework-level answer in magic, so it is tracked separately.