contact-item.ts 790 B

123456789101112131415161718192021222324252627282930313233
  1. import { ContactParams } from "./contact-params";
  2. export class ContactItem {
  3. public readonly data: ContactParams;
  4. public readonly id: string;
  5. public readonly hash: string;
  6. public readonly addrs: string[];
  7. public readonly groups: string[];
  8. constructor(props: ContactParams) {
  9. this.data = props;
  10. this.hash = props.hash;
  11. this.id = props.id;
  12. this.addrs = props.addrs || [];
  13. this.groups = props.groups || [];
  14. }
  15. public matchesAddressOrName(search: string) {
  16. if (this.addrs.filter(x => x.indexOf(search.trim()) >= 0)[0].length > 0) {
  17. return true;
  18. }
  19. return false;
  20. }
  21. public matchesGroup(group: string) {
  22. if (this.groups.filter(x => x === group.trim())[0].length > 0) {
  23. return true;
  24. }
  25. return false;
  26. }
  27. }