소스 검색

Fix don't inspect systemContact if not defined (#634)

Lennart Grahl 6 년 전
부모
커밋
02a4e346fe
2개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 2
      src/partials/messenger.ts
  2. 3 2
      src/services/webclient.ts

+ 4 - 2
src/partials/messenger.ts

@@ -1275,8 +1275,10 @@ class ReceiverDetailController {
 
             this.contactService.requiredDetails(contactReceiver)
                 .then(() => {
-                    this.hasSystemEmails = contactReceiver.systemContact.emails.length > 0;
-                    this.hasSystemPhones = contactReceiver.systemContact.phoneNumbers.length > 0;
+                    this.hasSystemEmails = contactReceiver.systemContact !== undefined
+                        && contactReceiver.systemContact.emails.length > 0;
+                    this.hasSystemPhones = contactReceiver.systemContact !== undefined &&
+                        contactReceiver.systemContact.phoneNumbers.length > 0;
                 })
                 .catch((error) => {
                     // TODO: Redirect or show an alert?

+ 3 - 2
src/services/webclient.ts

@@ -2181,9 +2181,10 @@ export class WebClientService {
         // Set contact detail
         const contactReceiver = this.receivers.contacts
             .get(args[WebClientService.ARGUMENT_IDENTITY]) as threema.ContactReceiver;
-        if (hasValue(data[WebClientService.SUB_TYPE_RECEIVER])) {
+        const receiver = data[WebClientService.SUB_TYPE_RECEIVER];
+        if (hasValue(receiver)) {
             contactReceiver.systemContact =
-                data[WebClientService.SUB_TYPE_RECEIVER][WebClientService.ARGUMENT_SYSTEM_CONTACT];
+                receiver[WebClientService.ARGUMENT_SYSTEM_CONTACT];
         }
         future.resolve(contactReceiver);
     }