contact-item.js 1.3 KB

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