Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't show the contact if the email is incorrect #2087

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ class NewMessageViewModel @Inject constructor(
fun arrivedFromExistingDraft() = arrivedFromExistingDraft
fun draftLocalUuid() = draftLocalUuid
fun draftMode() = draftMode
fun recipient() = recipient
fun shouldLoadDistantResources() = shouldLoadDistantResources

fun initDraftAndViewModel(intent: Intent): LiveData<Draft?> = liveData(ioCoroutineContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ class RecipientFieldView @JvmOverloads constructor(
onContactClicked = { addRecipient(it.email, it.name) },
onAddUnrecognizedContact = {
val input = textInput.text.toString()
if (input.isEmail()) {
addRecipient(email = input, name = input)
} else {
snackbarManager.setValue(context.getString(R.string.addUnknownRecipientInvalidEmail))
}
addRecipient(email = input, name = input)
},
snackbarManager = snackbarManager,
)
Expand Down Expand Up @@ -312,6 +308,11 @@ class RecipientFieldView @JvmOverloads constructor(

private fun addRecipient(email: String, name: String) {

if (!email.isEmail()) {
snackbarManager.setValue(context.getString(R.string.addUnknownRecipientInvalidEmail))
return
}

if (contactChipAdapter.itemCount > MAX_ALLOWED_RECIPIENT) {
snackbarManager.setValue(context.getString(R.string.tooManyRecipients))
return
Expand Down
Loading