@@ -44,14 +44,15 @@ import kotlinx.coroutines.flow.flowOn
4444import kotlinx.coroutines.flow.receiveAsFlow
4545import kotlinx.coroutines.flow.stateIn
4646import kotlinx.coroutines.launch
47+ import kotlinx.coroutines.withContext
4748
4849class DuckChatSettingsViewModel @AssistedInject constructor(
4950 @Assisted duckChatActivityParams : GlobalActivityStarter .ActivityParams ,
5051 private val duckChat : DuckChatInternal ,
5152 private val pixel : Pixel ,
5253 private val inputScreenDiscoveryFunnel : InputScreenDiscoveryFunnel ,
5354 private val settingsPageFeature : SettingsPageFeature ,
54- dispatcherProvider : DispatcherProvider ,
55+ private val dispatcherProvider : DispatcherProvider ,
5556) : ViewModel() {
5657 private val commandChannel = Channel <Command >(capacity = 1 , onBufferOverflow = DROP_OLDEST )
5758 val commands = commandChannel.receiveAsFlow()
@@ -142,11 +143,15 @@ class DuckChatSettingsViewModel @AssistedInject constructor(
142143
143144 fun duckChatSearchAISettingsClicked () {
144145 viewModelScope.launch {
146+ val hideAiGeneratedImagesOptionEnabled = withContext(dispatcherProvider.io()) {
147+ settingsPageFeature.hideAiGeneratedImagesOption().isEnabled()
148+ }
149+
145150 if (settingsPageFeature.embeddedSettingsWebView().isEnabled()) {
146151 commandChannel.send(
147152 OpenLink (
148153 link = DUCK_CHAT_SEARCH_AI_SETTINGS_LINK_EMBEDDED ,
149- titleRes = if (settingsPageFeature.hideAiGeneratedImagesOption().isEnabled() ) {
154+ titleRes = if (hideAiGeneratedImagesOptionEnabled ) {
150155 R .string.duckAiSerpSettingsTitle
151156 } else {
152157 R .string.duck_chat_assist_settings_title
0 commit comments