Skip to content

Commit

Permalink
Added more cases for valid and invalid emails, refactored some code |…
Browse files Browse the repository at this point in the history
… Last commit for change PR to review

Signed-off-by: Andrii Rublov <airublev@outlook.com>
  • Loading branch information
Andrii Rublov committed Feb 23, 2024
1 parent 4adceef commit 6e9e6a0
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,11 @@ export default {
if (char === '@' || inEmail) {
inEmail = true
if (char === ';' || char === ',' || char === ' ') {
if ([';', ',', ' '].includes(char)) {
let stringAddress = string.substring(start, i).trim()
let labelAndAddress = this.getLabelAndAddress(stringAddress)
if(labelAndAddress) {
if (labelAndAddress) {
list.push(labelAndAddress)
}
Expand All @@ -1256,35 +1256,30 @@ export default {
let stringAddress = string.substring(start).trim()
let labelAndAddress = this.getLabelAndAddress(stringAddress)
if(labelAndAddress) {
if (labelAndAddress) {
list.push(labelAndAddress)
}
}
return list
},
pushNewAddr(option, list){
if (list.some((recipient) => recipient.email === option.email)) {
return
}
const recipient = { ...option }
this.newRecipients.push(recipient)
list.push(recipient)
this.saveDraftDebounced()
},
onNewAddr(option, list) {
if(option.id) {
if (list.some((recipient) => recipient.email === option.email)) {
return
}
const recipient = { ...option }
this.newRecipients.push(recipient)
list.push(recipient)
this.saveDraftDebounced()
} else{
if (option.id) {
this.pushNewAddr(option, list)
} else {
const emailList = this.parseEmailList(option.email)
emailList.forEach(email => {
if (list.some((recipient) => recipient.email === email.email)) {
return
}
const recipient = { ...email }
this.newRecipients.push(recipient)
list.push(recipient)
this.saveDraftDebounced()
});
emailList.forEach(email => this.pushNewAddr(email, list));
}
},
async onSend(_, force = false) {
Expand Down

0 comments on commit 6e9e6a0

Please sign in to comment.