| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- class ContentItem {
- constructor(props) {
- this.data = props;
- this.id = props.id;
- this.type = props.type;
- if (props.myTags) {
- this.myTagsWithoutAll = props.myTags.filter(x => x !== 'all');
- }
- else {
- this.myTagsWithoutAll = [];
- }
- if (props.price != null && !isNaN(Number(props.price))) {
- 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];
- if (this.fromTarget && this.toTarget && this.media) {
- this.repliable = true;
- }
- else {
- this.repliable = false;
- }
- }
- formatCents(price) {
- if (price == null || price === 0) {
- return 'free';
- }
- let dollars = `${price / 100}`;
- if (dollars.match(/\..$/)) {
- dollars += '0';
- }
- return '$' + dollars;
- }
- }
- exports.ContentItem = ContentItem;
- //# sourceMappingURL=content-item.js.map
|