Skip to content

Commit

Permalink
Show on App Launch: Fix option observation race condition (#5307)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/488551667048375/1208815135507669/f

### Description

Added a null check to the ViewState when attempting to update via
observing the selected ShowOnAppLaunch option.

### Steps to test this PR

- [ ] Launch the app and navigate to General Settings
- [ ] There should be no crash
- [ ] Open the Show on App Launch screen
- [ ] Change your option
- [ ] Navigate back
- [ ] The new Show on App Launch function should still be reflected on
the General Settings screen

### UI changes
No UI changes
  • Loading branch information
mikescamell authored Nov 25, 2024
1 parent 5dd2355 commit d81c9a7
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class GeneralSettingsViewModel @Inject constructor(
private fun observeShowOnAppLaunchOption() {
showOnAppLaunchOptionDataStore.optionFlow
.onEach { showOnAppLaunchOption ->
_viewState.update { it!!.copy(showOnAppLaunchSelectedOption = showOnAppLaunchOption) }
_viewState.value?.let { state -> _viewState.update { state.copy(showOnAppLaunchSelectedOption = showOnAppLaunchOption) } }
}.launchIn(viewModelScope)
}

Expand Down

0 comments on commit d81c9a7

Please sign in to comment.