user 6 years ago
parent
commit
237f21b312
5 changed files with 19 additions and 19 deletions
  1. 8 8
      lib/content-item.js
  2. 1 1
      lib/content-item.js.map
  3. 1 1
      lib/content-params.d.ts
  4. 8 8
      src/content-item.ts
  5. 1 1
      src/content-params.ts

+ 8 - 8
lib/content-item.js

@@ -15,14 +15,14 @@ class ContentItem {
             this.price = Number(props.price);
             this.priceFormatted = this.formatCents(this.price);
         }
-        this.allLinks = props.links;
-        this.userLinks = props.links.filter(x => !x.rel.startsWith('.'));
-        this.systemLinks = props.links.filter(x => x.rel.startsWith('.'));
-        this.fromTarget = props.links.filter(x => x.rel === '.from').map(x => x.target)[0];
-        this.toTarget = props.links.filter(x => x.rel === '.to').map(x => x.target)[0];
-        this.fromContactId = props.links.filter(x => x.rel === '.from-contact-id').map(x => x.target)[0];
-        this.toContactId = props.links.filter(x => x.rel === '.to-contact-id').map(x => x.target)[0];
-        this.media = props.links.filter(x => x.rel === '.media').map(x => x.target)[0];
+        this.allLinks = props.links || [];
+        this.userLinks = this.allLinks.filter(x => !x.rel.startsWith('.'));
+        this.systemLinks = this.allLinks.filter(x => x.rel.startsWith('.'));
+        this.fromTarget = this.allLinks.filter(x => x.rel === '.from').map(x => x.target)[0];
+        this.toTarget = this.allLinks.filter(x => x.rel === '.to').map(x => x.target)[0];
+        this.fromContactId = this.allLinks.filter(x => x.rel === '.from-contact-id').map(x => x.target)[0];
+        this.toContactId = this.allLinks.filter(x => x.rel === '.to-contact-id').map(x => x.target)[0];
+        this.media = this.allLinks.filter(x => x.rel === '.media').map(x => x.target)[0];
         if (this.fromTarget && this.toTarget && this.media) {
             this.repliable = true;
         }

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


+ 1 - 1
lib/content-params.d.ts

@@ -2,7 +2,7 @@ import { ContentLink } from "./content-link";
 export interface ContentParams {
     id: string;
     type: string;
-    links: ContentLink[];
+    links?: ContentLink[];
     myTags?: string[];
     price?: number;
 }

+ 8 - 8
src/content-item.ts

@@ -35,15 +35,15 @@ export class ContentItem {
       this.price = Number(props.price);
       this.priceFormatted = this.formatCents(this.price);
     }
-    this.allLinks = props.links;
-    this.userLinks = props.links.filter(x => !x.rel.startsWith('.'));
-    this.systemLinks = props.links.filter(x => x.rel.startsWith('.'));
+    this.allLinks = props.links || [];
+    this.userLinks = this.allLinks.filter(x => !x.rel.startsWith('.'));
+    this.systemLinks = this.allLinks.filter(x => x.rel.startsWith('.'));
 
-    this.fromTarget = props.links.filter(x => x.rel === '.from').map(x => x.target)[0];
-    this.toTarget = props.links.filter(x => x.rel === '.to').map(x => x.target)[0];
-    this.fromContactId = props.links.filter(x => x.rel === '.from-contact-id').map(x => x.target)[0];
-    this.toContactId = props.links.filter(x => x.rel === '.to-contact-id').map(x => x.target)[0];
-    this.media = props.links.filter(x => x.rel === '.media').map(x => x.target)[0];
+    this.fromTarget = this.allLinks.filter(x => x.rel === '.from').map(x => x.target)[0];
+    this.toTarget = this.allLinks.filter(x => x.rel === '.to').map(x => x.target)[0];
+    this.fromContactId = this.allLinks.filter(x => x.rel === '.from-contact-id').map(x => x.target)[0];
+    this.toContactId = this.allLinks.filter(x => x.rel === '.to-contact-id').map(x => x.target)[0];
+    this.media = this.allLinks.filter(x => x.rel === '.media').map(x => x.target)[0];
     if (this.fromTarget && this.toTarget && this.media) {
       this.repliable = true;
     } else {

+ 1 - 1
src/content-params.ts

@@ -3,7 +3,7 @@ import { ContentLink } from "./content-link";
 export interface ContentParams {
     id: string;
     type: string;
-    links: ContentLink[];
+    links?: ContentLink[];
     myTags?: string[];
     price?: number;
 }