contact-item.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. class ContactItem {
  4. constructor(props) {
  5. this.data = props;
  6. this.hash = props.hash;
  7. this.id = props.id;
  8. this.addrs = props.addrs || [];
  9. this.groups = props.groups || [];
  10. }
  11. matchesAddressOrName(search) {
  12. if (this.addrs.filter(x => x.indexOf(search.trim()) >= 0)[0].length > 0) {
  13. return true;
  14. }
  15. return false;
  16. }
  17. matchesGroup(group) {
  18. if (this.groups.filter(x => x === group.trim())[0].length > 0) {
  19. return true;
  20. }
  21. return false;
  22. }
  23. getFirstEmail() {
  24. const prefixed = this.addrs.filter(x => x.startsWith('email:'))[0];
  25. if (prefixed == null) {
  26. return undefined;
  27. }
  28. return prefixed.substring(6);
  29. }
  30. getMatchingAddresses() {
  31. return this.addrs.filter(x => x.indexOf(x) >= 0);
  32. }
  33. }
  34. exports.ContactItem = ContactItem;
  35. //# sourceMappingURL=contact-item.js.map