Skip to content

Commit f2b5ba8

Browse files
committed
Access directly the editor empty status when navigating to the AiPropositionFragment
1 parent e14e168 commit f2b5ba8

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageAiManager.kt

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import com.infomaniak.mail.utils.extensions.observeNotNull
4444
import com.infomaniak.mail.utils.extensions.updateNavigationBarColor
4545
import dagger.hilt.android.qualifiers.ActivityContext
4646
import dagger.hilt.android.scopes.FragmentScoped
47-
import kotlinx.coroutines.Dispatchers
4847
import kotlinx.coroutines.delay
4948
import kotlinx.coroutines.launch
5049
import javax.inject.Inject
@@ -231,18 +230,12 @@ class NewMessageAiManager @Inject constructor(
231230
closeAiPrompt(becauseOfGeneration = true)
232231
resetAiProposition()
233232

234-
// TODO: Find out if body is empty
235-
// TODO: Review this part
236-
binding.editor.exportHtml {
237-
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) {
238-
fragment.safeNavigate(
239-
NewMessageFragmentDirections.actionNewMessageFragmentToAiPropositionFragment(
240-
isSubjectBlank = fragment.isSubjectBlank(),
241-
isBodyBlank = it.isBlank(),
242-
),
243-
)
244-
}
245-
}
233+
fragment.safeNavigate(
234+
NewMessageFragmentDirections.actionNewMessageFragmentToAiPropositionFragment(
235+
isSubjectBlank = fragment.isSubjectBlank(),
236+
isBodyBlank = binding.editor.isEmptyFlow.value ?: true,
237+
),
238+
)
246239
}
247240

248241
fun openAiPrompt() {

0 commit comments

Comments
 (0)