Skip to content

[compass_app] Scope LogoutViewModel to route builder — fix #2604#2819

Open
mozammal-hossain wants to merge 2 commits intoflutter:mainfrom
mozammal-hossain:fix/logoutViewModel-rebuild-on-state-change
Open

[compass_app] Scope LogoutViewModel to route builder — fix #2604#2819
mozammal-hossain wants to merge 2 commits intoflutter:mainfrom
mozammal-hossain:fix/logoutViewModel-rebuild-on-state-change

Conversation

@mozammal-hossain
Copy link
Copy Markdown

Description

Problem: LogoutViewModel was built inside HomeHeader.build(), so each rebuild could create a new instance and a new logout command. That does not match how other Compass view models are scoped (created in the GoRouter route builder and passed in), and it can affect an in-flight logout when the home screen rebuilds.

Change: Create LogoutViewModel once in the /home route next to HomeViewModel, pass it through HomeScreenHomeHeaderLogoutButton, and remove inline construction in home_title.dart. Update home_screen_test.dart to build LogoutViewModel with fakes and remove Provider wrappers that only supported context.read() in the header.

Result: Logout view model lifetime aligns with the home route; no visual or copy changes (screenshots not needed).

Fixes #2604


Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-devrel channel on Discord.

- Added LogoutViewModel to HomeScreen for managing user logout.
- Updated HomeHeader to utilize the new LogoutViewModel.
- Refactored HomeScreen tests to include LogoutViewModel initialization.
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.

[Compass app] Viewmodels being rebuild on state change

1 participant