snappymail/dev/Model/Identity.js

38 lines
647 B
JavaScript
Raw Normal View History

2019-07-05 03:19:24 +08:00
import { AbstractModel } from 'Knoin/AbstractModel';
import { addObservablesTo } from 'External/ko';
2016-07-07 05:03:30 +08:00
2021-01-22 23:32:08 +08:00
export class IdentityModel extends AbstractModel {
2016-07-07 05:03:30 +08:00
/**
* @param {string} id
* @param {string} email
*/
2023-02-21 23:02:22 +08:00
constructor() {
2020-10-19 01:19:45 +08:00
super();
2016-07-07 05:03:30 +08:00
addObservablesTo(this, {
2023-02-21 23:02:22 +08:00
id: '',
2024-02-09 09:39:00 +08:00
label: '',
2023-02-21 23:02:22 +08:00
email: '',
2020-10-25 18:46:58 +08:00
name: '',
2016-07-07 05:03:30 +08:00
2020-10-25 18:46:58 +08:00
replyTo: '',
bcc: '',
2016-07-07 05:03:30 +08:00
2020-10-25 18:46:58 +08:00
signature: '',
signatureInsertBefore: false,
askDelete: false
2020-10-25 18:46:58 +08:00
});
2016-07-07 05:03:30 +08:00
}
/**
* @returns {string}
*/
formattedName() {
2019-07-05 03:19:24 +08:00
const name = this.name(),
2024-02-09 09:39:00 +08:00
email = this.email(),
label = this.label();
return (name ? `${name} ` : '') + `<${email}>` + (label ? ` (${label})` : '');
2016-07-07 05:03:30 +08:00
}
}