user 6 jaren geleden
bovenliggende
commit
6ea931b10e
4 gewijzigde bestanden met toevoegingen van 19 en 3 verwijderingen
  1. 1 0
      lib/contact-item.d.ts
  2. 7 0
      lib/contact-item.js
  3. 1 1
      lib/contact-item.js.map
  4. 10 2
      src/contact-item.ts

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

@@ -8,4 +8,5 @@ export declare class ContactItem {
     constructor(props: ContactParams);
     matchesAddressOrName(search: string): boolean;
     matchesGroup(group: string): boolean;
+    getFirstEmail(): string | undefined;
 }

+ 7 - 0
lib/contact-item.js

@@ -20,6 +20,13 @@ class ContactItem {
         }
         return false;
     }
+    getFirstEmail() {
+        const prefixed = this.addrs.filter(x => x.startsWith('email:'))[0];
+        if (prefixed == null) {
+            return undefined;
+        }
+        return prefixed.substring(6);
+    }
 }
 exports.ContactItem = ContactItem;
 //# sourceMappingURL=contact-item.js.map

File diff suppressed because it is too large
+ 1 - 1
lib/contact-item.js.map


+ 10 - 2
src/contact-item.ts

@@ -16,17 +16,25 @@ export class ContactItem {
     this.groups = props.groups || [];
   }
 
-  public matchesAddressOrName(search: string) {
+  public matchesAddressOrName(search: string): boolean {
       if (this.addrs.filter(x => x.indexOf(search.trim()) >= 0)[0].length > 0) {
           return true;
       }
       return false;
   }
 
-  public matchesGroup(group: string) {
+  public matchesGroup(group: string): boolean {
     if (this.groups.filter(x => x === group.trim())[0].length > 0) {
         return true;
     }
     return false;
   }
+
+  public getFirstEmail(): string | undefined {
+      const prefixed = this.addrs.filter(x => x.startsWith('email:'))[0];
+      if (prefixed == null) {
+          return undefined;
+      }
+      return prefixed.substring(6);
+  }
 }