Fix image filtering#533
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the onFilterChanged function in ImagesViewModel to emit the new filter text. The reviewer suggests optimizing this by directly setting the StateFlow value synchronously (filter.value = text) and removing the unnecessary coroutine wrapper.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| fun onFilterChanged(text: String) { | ||
| viewModelScope.launch(dispatcherProvider.viewModel) { | ||
| filter.emit(text) |
There was a problem hiding this comment.
For MutableStateFlow, you can update the value synchronously using filter.value = text instead of calling the suspending emit(text) function. Furthermore, because updating a StateFlow's value is synchronous and thread-safe, you do not need to launch a coroutine via viewModelScope.launch at all. You should remove the coroutine wrapper and update the value directly.
| filter.emit(text) | |
| filter.value = text |
Fixes the filtering for images. This line probably got deleted on accident