google / google/ground-android

[Code health] Composure Dialogs should use state variables passed in from their ViewModels, not local MutableStates

Open
#2,647 0 comments 0 reactions 0 assignees View on GitHub
type: code health
Dominant language
Kotlin
Stars
293
Forks
149
Avg merge
1d 16h
Merged PRs (30d)
42

Description

From @anandwana001:

> Rather than passing MutableState and bringing the variable modification responsibility to compose function, we can leverage the ViewModel with some event structure, where the variable modification can be moved to viewModel and compose responsibility is just to deliver that event to viewModel.

https://github.com/google/ground-android/pull/2637#discussion_r1714946630

This is evident when you switch contexts, sometimes the dialog renders twice as a result! Instead, we should build a state variable that is updated at the ViewModel level which we pass through here. In that PR, I was following an existing pattern, which means we should try to fix this across all the `*Dialog` classes.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.