|
|
@@ -42,10 +42,33 @@ export class ContactItem {
|
|
|
return prefixed.substring(6);
|
|
|
}
|
|
|
|
|
|
+ public getFirstPhone(): string | undefined {
|
|
|
+ const prefixed = this.addrs.filter(x => x.startsWith('phone:'))[0];
|
|
|
+ if (prefixed == null) {
|
|
|
+ return undefined;
|
|
|
+ }
|
|
|
+ return prefixed.substring(6);
|
|
|
+}
|
|
|
+
|
|
|
public getMatchingAddresses(search: string): string[] {
|
|
|
return this.addrs.filter(x => x.indexOf(search) >= 0);
|
|
|
}
|
|
|
|
|
|
+ public getName(): string {
|
|
|
+ if (this.names.length > 0) {
|
|
|
+ return this.names[0];
|
|
|
+ }
|
|
|
+ const firstEmail = this.getFirstEmail();
|
|
|
+ if (firstEmail != null) {
|
|
|
+ return firstEmail;
|
|
|
+ }
|
|
|
+ const firstPhone = this.getFirstPhone();
|
|
|
+ if (firstPhone != null) {
|
|
|
+ return firstPhone;
|
|
|
+ }
|
|
|
+ return 'New contact ' + this.id.substring(0,8);
|
|
|
+ }
|
|
|
+
|
|
|
public getData(): ContactParams {
|
|
|
return {
|
|
|
addrs: this.addrs,
|