contact-item.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. this.notes = props.notes || '';
  11. }
  12. matchesAddressOrName(search) {
  13. if (this.addrs.filter(x => x.indexOf(search.trim()) >= 0).length > 0) {
  14. return true;
  15. }
  16. return false;
  17. }
  18. matchesGroup(group) {
  19. if (this.groups.filter(x => x === group.trim())[0].length > 0) {
  20. return true;
  21. }
  22. return false;
  23. }
  24. getFirstEmail() {
  25. const prefixed = this.addrs.filter(x => x.startsWith('email:'))[0];
  26. if (prefixed == null) {
  27. return undefined;
  28. }
  29. return prefixed.substring(6);
  30. }
  31. getMatchingAddresses(search) {
  32. return this.addrs.filter(x => x.indexOf(search) >= 0);
  33. }
  34. getData() {
  35. return {
  36. addrs: this.addrs,
  37. groups: this.groups,
  38. hash: this.hash,
  39. id: this.id,
  40. notes: this.notes
  41. };
  42. }
  43. }
  44. exports.ContactItem = ContactItem;
  45. //# sourceMappingURL=contact-item.js.map