user před 6 roky
rodič
revize
671d5b2ad3

+ 1 - 0
lib/contact-book.d.ts

@@ -6,6 +6,7 @@ export declare class ContactBook {
     getPrimaryPhoneNumber(): string | undefined;
     getFromPhoneNumbers(): string[];
     getFromEmailAddresses(): string[];
+    getAllGroups(): string[];
     lookupByAddress(addressType: string, addressValue: string): ContactItem | undefined;
     lookupById(id: string): ContactItem | undefined;
     search(search: string): ContactItem[];

+ 8 - 0
lib/contact-book.js

@@ -33,6 +33,14 @@ class ContactBook {
         }
         return result;
     }
+    getAllGroups() {
+        return Object.keys(this.items.reduce((accum, contact) => {
+            for (const group of contact.groups) {
+                accum[group] = true;
+            }
+            return accum;
+        }, {}));
+    }
     lookupByAddress(addressType, addressValue) {
         return this.items.find(item => item.matchesAddressExactly(addressType, addressValue));
     }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
lib/contact-book.js.map


+ 1 - 0
lib/contact-item.d.ts

@@ -14,6 +14,7 @@ export declare class ContactItem {
     getFirstEmail(): string | undefined;
     getFirstPhone(): string | undefined;
     search(search: string): boolean;
+    getMatchingAddresses(search: string): ContactAddress[];
     matchesAddressExactly(addressType: string, addressValue: string): boolean;
     generateName(): string;
     getName(): string;

+ 3 - 0
lib/contact-item.js

@@ -44,6 +44,9 @@ class ContactItem {
         }
         return false;
     }
+    getMatchingAddresses(search) {
+        return this.addrs.filter(addr => addr.matches(search));
+    }
     matchesAddressExactly(addressType, addressValue) {
         if (this.addrs.find(addr => addr.matchesExactly(addressType, addressValue))) {
             return true;

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
lib/contact-item.js.map


+ 10 - 1
src/contact-book.ts

@@ -1,5 +1,5 @@
-import { ContactItem } from "./contact-item";
 import { ContactAddress } from "./contact-address";
+import { ContactItem } from "./contact-item";
 
 export class ContactBook {
 
@@ -41,6 +41,15 @@ export class ContactBook {
     return result;
   }
 
+  public getAllGroups(): string[] {
+    return Object.keys(this.items.reduce((accum, contact) => {
+      for (const group of contact.groups) {
+        accum[group] = true;
+      }
+      return accum;
+    }, {}));
+  }
+
   public lookupByAddress(addressType: string, addressValue: string): ContactItem | undefined {
     return this.items.find(item => item.matchesAddressExactly(addressType, addressValue));
   }

+ 4 - 0
src/contact-item.ts

@@ -60,6 +60,10 @@ export class ContactItem {
     return false;
   }
 
+  public getMatchingAddresses(search: string): ContactAddress[] {
+    return this.addrs.filter(addr => addr.matches(search));
+  }
+
   public matchesAddressExactly(addressType: string, addressValue: string): boolean {
     if (this.addrs.find(addr => addr.matchesExactly(addressType, addressValue))) {
       return true;