Browse Source

Fix error link not available

Fixes:

Exception in template helper: TypeError: Cannot read property 'link' of undefined
    at constructor.attachmentLink (http://192.168.178.2:8080/app/app.js?hash=c0f961362c1318d650abaafcaaa6f6a77c8d11c8:3935:29)
    at http://192.168.178.2:8080/packages/blaze.js?hash=a20deb597f76789e171a9ee2b2e37d73fbb7ecda:1566:16
    at http://192.168.178.2:8080/packages/peerlibrary_blaze-components.js?hash=4049f7e3116e3d9e865392b9546e70dc479b9add:395:66
    at Function.Template._withTemplateInstanceFunc (http://192.168.178.2:8080/packages/blaze.js?hash=a20deb597f76789e171a9ee2b2e37d73fbb7ecda:3575:14)
    at http://192.168.178.2:8080/packages/peerlibrary_blaze-components.js?hash=4049f7e3116e3d9e865392b9546e70dc479b9add:394:27
    at Spacebars.call (http://192.168.178.2:8080/packages/spacebars.js?hash=6f2be25813c793c0b363a6a91ebb029723f294ec:169:51)
    at Spacebars.mustacheImpl (http://192.168.178.2:8080/packages/spacebars.js?hash=6f2be25813c793c0b363a6a91ebb029723f294ec:106:25)
    at Object.Spacebars.mustache (http://192.168.178.2:8080/packages/spacebars.js?hash=6f2be25813c793c0b363a6a91ebb029723f294ec:110:39)
    at Blaze.View._render (http://192.168.178.2:8080/app/app.js?hash=c0f961362c1318d650abaafcaaa6f6a77c8d11c8:3328:42)
    at Blaze.View.doRender (http://192.168.178.2:8080/packages/blaze.js?hash=a20deb597f76789e171a9ee2b2e37d73fbb7ecda:1925:25)
Marc Hartmayer 5 years ago
parent
commit
b7105d7b57
1 changed files with 4 additions and 3 deletions
  1. 4 3
      client/components/activities/activities.js

+ 4 - 3
client/components/activities/activities.js

@@ -151,8 +151,9 @@ BlazeComponent.extendComponent({
   },
 
   attachmentLink() {
-    const attachment = this.currentData().activity.attachment();
-    const link = attachment.link('original', '/');
+    const activity = this.currentData().activity;
+    const attachment = activity.attachment();
+    const link = attachment ? attachment.link('original', '/') : null;
     // trying to display url before file is stored generates js errors
     return (
       (attachment &&
@@ -166,7 +167,7 @@ BlazeComponent.extendComponent({
             attachment.name,
           ),
         )) ||
-      this.currentData().activity.attachmentName
+      activity.attachmentName
     );
   },