Skip to content

Wait for switched user's home settings before fetching data - #1981

Merged
damontecres merged 2 commits into
mainfrom
fix/home-race-condition
Sep 17, 2026
Merged

damontecres merged 2 commits into
mainfrom
fix/home-race-condition

Conversation

@damontecres

Copy link
Copy Markdown
Owner

Description

There is a race condition when switching users between HomeViewModel.init and HomeSetttingsService.loadCurrentSettings. This happens more often if the new user doesn't have a customized home page. The result is that the previous user's home page settings are used for the initial load of the home page.

This PR fixes this by collecting the flows for current user & home settings, waiting until both are valid and refer to the same user, then fetch the data.

Related issues

Fixes #1976
Maybe related (and fixes) #1980, but need to investigate more

Testing

Emulator. It's easy to reproduce by adding a manual delay(2.seconds) at the start of HomeSetttingsService.loadCurrentSettings.

Screenshots

N/A

AI or LLM usage

None

@damontecres damontecres added the bug Something isn't working label Sep 16, 2026
@damontecres
damontecres merged commit 32a56e8 into main Sep 17, 2026
2 checks passed
@damontecres
damontecres deleted the fix/home-race-condition branch September 17, 2026 18:41
damontecres added a commit that referenced this pull request Sep 28, 2026
## Description
Fixes the home page reloading from scratch when the app is resumed

This happened because the `userDto` is updated on app resume and since
it has a last accessed timestamp, it would always different and trigger
a reload.

### Related issues
Bug introduced by #1981

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect home rows after switching user

1 participant