@social-mail/social-mail-client 1.4.160 → 1.4.161

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31740,29 +31740,36 @@ System.register(["tslib", "@web-atoms/core/dist/di/Inject", "../EntityService",
31740
31740
  }
31741
31741
  search(mailboxID, search, cancelToken) {
31742
31742
  return __awaiter(this, void 0, void 0, function* () {
31743
- const [contacts, emails] = yield Promise.all([this.searchContacts(mailboxID, search, cancelToken), this.searchEmails(search, cancelToken)]);
31744
- for (const e of emails) {
31745
- if (contacts.some(c => c.emailAddressID === e.emailAddressID)) {
31746
- continue;
31747
- }
31748
- contacts.push(e);
31749
- }
31743
+ const contacts = [];
31744
+ const set = new Set();
31745
+ yield this.populateContacts(set, contacts, mailboxID, search, true, cancelToken);
31746
+ (() => __awaiter(this, void 0, void 0, function* () {
31747
+ yield this.populateEmails(set, contacts, search, true, cancelToken);
31748
+ yield Promise.all([this.populateContacts(set, contacts, mailboxID, search, false, cancelToken), this.populateEmails(set, contacts, search, false, cancelToken)]);
31749
+ }))().catch(console.error);
31750
31750
  return contacts;
31751
31751
  });
31752
31752
  }
31753
- searchContacts(mailboxID, search, cancelToken) {
31753
+ populateContacts(set, contacts, mailboxID, search, exact, cancelToken) {
31754
31754
  return __awaiter(this, void 0, void 0, function* () {
31755
31755
  if (!search) {
31756
- return [];
31756
+ return;
31757
31757
  }
31758
- let q = this.entityService.query(MailboxContact);
31758
+ let q = this.entityService.query(MailboxContact).where({
31759
+ mailboxID
31760
+ }, p => x => x.mailboxID === p.mailboxID);
31759
31761
  if (!/\%$/.test(search)) {
31760
31762
  search = `${search}%`.toLocaleLowerCase();
31761
31763
  }
31762
- q = q.where({
31763
- search,
31764
- mailboxID
31765
- }, p => x => x.mailboxID === p.mailboxID && (Sql.text.like(x.emailAddress.emailAddress, p.search) || Sql.text.like(x.emailAddress.name, p.search) || x.emailAddress.names.some(n => Sql.text.like(n.nameToken.word, p.search))));
31764
+ if (exact) {
31765
+ q = q.where({
31766
+ search
31767
+ }, p => x => Sql.text.like(x.emailAddress.emailAddress, p.search) || Sql.text.like(x.emailAddress.name, p.search));
31768
+ } else {
31769
+ q = q.where({
31770
+ search
31771
+ }, p => x => x.emailAddress.names.some(n => Sql.text.like(n.nameToken.word, p.search)));
31772
+ }
31766
31773
  const list = yield q.include(x => x.emailAddress).orderByDescending(x => x.dateUpdated).toPagedList({
31767
31774
  start: 0,
31768
31775
  size: 10,
@@ -31772,26 +31779,36 @@ System.register(["tslib", "@web-atoms/core/dist/di/Inject", "../EntityService",
31772
31779
  cancelToken,
31773
31780
  hideActivityIndicator
31774
31781
  });
31775
- return list.items.map(x => x.emailAddress);
31782
+ for (const {
31783
+ emailAddress
31784
+ } of list.items) {
31785
+ if (set.has(emailAddress.emailAddressID)) {
31786
+ continue;
31787
+ }
31788
+ set.add(emailAddress.emailAddressID);
31789
+ contacts.add(emailAddress);
31790
+ }
31776
31791
  });
31777
31792
  }
31778
- searchEmails(search, cancelToken) {
31793
+ populateEmails(set, contacts, search, exact, cancelToken) {
31779
31794
  return __awaiter(this, void 0, void 0, function* () {
31780
31795
  if (!search) {
31781
- return [];
31796
+ return;
31782
31797
  }
31783
31798
  let q = this.entityService.query(EmailAddress);
31784
31799
  if (!/\%$/.test(search)) {
31785
31800
  search = `${search}%`.toLocaleLowerCase();
31801
+ }
31802
+ if (exact) {
31786
31803
  q = q.where({
31787
31804
  search
31788
31805
  }, p => x => Sql.text.like(x.emailAddress, p.search) || Sql.text.like(x.name, p.search));
31789
31806
  } else {
31790
31807
  q = q.where({
31791
31808
  search
31792
- }, p => x => Sql.text.iLike(x.emailAddress, p.search) || Sql.text.iLike(x.name, p.search));
31809
+ }, p => x => x.names.some(n => Sql.text.like(n.nameToken.word, p.search)));
31793
31810
  }
31794
- const list = yield q.orderBy(x => x.emailAddress).toPagedList({
31811
+ const list = yield q.orderBy(x => x.name).toPagedList({
31795
31812
  start: 0,
31796
31813
  size: 10,
31797
31814
  count: false,
@@ -31800,7 +31817,13 @@ System.register(["tslib", "@web-atoms/core/dist/di/Inject", "../EntityService",
31800
31817
  cancelToken,
31801
31818
  hideActivityIndicator
31802
31819
  });
31803
- return list.items;
31820
+ for (const emailAddress of list.items) {
31821
+ if (set.has(emailAddress.emailAddressID)) {
31822
+ continue;
31823
+ }
31824
+ set.add(emailAddress.emailAddressID);
31825
+ contacts.add(emailAddress);
31826
+ }
31804
31827
  });
31805
31828
  }
31806
31829
  };
@@ -34385,7 +34408,7 @@ System.register(["tslib", "@web-atoms/core/dist/core/InjectProperty", "@web-atom
34385
34408
  cacheVersion,
34386
34409
  cancelToken
34387
34410
  });
34388
- return items.items;
34411
+ return items.items.filter(x => x.emailAddress);
34389
34412
  });
34390
34413
  }
34391
34414
  });