IdentityModel extends EmailModel

This commit is contained in:
the-djmaze 2024-10-23 00:56:42 +02:00
parent b01072e2e3
commit f0b3d798bc
6 changed files with 27 additions and 21 deletions

View file

@ -73,4 +73,9 @@ export class EmailModel extends AbstractModel {
}
return result || name;
}
get domain() {
return this.email.replace(/^.+@([^@]+)$/, '$1');
// return this.email.slice(this.email.lastIndexOf('@'))
}
}

View file

@ -1,7 +1,8 @@
import { AbstractModel } from 'Knoin/AbstractModel';
//import { AbstractModel } from 'Knoin/AbstractModel';
import { EmailModel } from 'Model/Email';
import { addObservablesTo, addComputablesTo } from 'External/ko';
export class IdentityModel extends AbstractModel {
export class IdentityModel extends EmailModel /*AbstractModel*/ {
/**
* @param {string} id
* @param {string} email
@ -12,8 +13,8 @@ export class IdentityModel extends AbstractModel {
addObservablesTo(this, {
id: '',
label: '',
email: '',
name: '',
// email: '',
// name: '',
replyTo: '',
bcc: '',
@ -44,8 +45,8 @@ export class IdentityModel extends AbstractModel {
* @returns {string}
*/
formattedName() {
const name = this.name(),
email = this.email(),
const name = this.name,
email = this.email,
label = this.label();
return (name ? `${name} ` : '') + `<${email}>` + (label ? ` (${label})` : '');
}