| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- class ContactItem {
- constructor(props) {
- this.data = props;
- this.hash = props.hash;
- this.id = props.id;
- this.canSendFromAddrs = props.canSendFromAddrs || false;
- this.addrs = props.addrs || [];
- this.groups = props.groups || [];
- this.names = props.names || [];
- this.notes = props.notes || '';
- }
- matchesAddressOrName(search) {
- if (this.addrs.filter(x => x.indexOf(search.trim()) >= 0).length > 0) {
- return true;
- }
- return false;
- }
- matchesGroup(group) {
- if (this.groups.filter(x => x === group.trim())[0].length > 0) {
- return true;
- }
- return false;
- }
- getFirstEmail() {
- const prefixed = this.addrs.filter(x => x.startsWith('email:'))[0];
- if (prefixed == null) {
- return undefined;
- }
- return prefixed.substring(6);
- }
- getFirstPhone() {
- const prefixed = this.addrs.filter(x => x.startsWith('phone:'))[0];
- if (prefixed == null) {
- return undefined;
- }
- return prefixed.substring(6);
- }
- getMatchingAddresses(search) {
- return this.addrs.filter(x => x.indexOf(search) >= 0);
- }
- getName() {
- if (this.names.length > 0) {
- return this.names[0];
- }
- const firstEmail = this.getFirstEmail();
- if (firstEmail != null) {
- return firstEmail;
- }
- const firstPhone = this.getFirstPhone();
- if (firstPhone != null) {
- return firstPhone;
- }
- return 'New contact ' + this.id.substring(0, 8);
- }
- getData() {
- return {
- addrs: this.addrs,
- canSendFromAddrs: this.canSendFromAddrs,
- groups: this.groups,
- hash: this.hash,
- id: this.id,
- names: this.names,
- notes: this.notes
- };
- }
- }
- exports.ContactItem = ContactItem;
- //# sourceMappingURL=contact-item.js.map
|