| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- class ContentItem {
- constructor(hashInPlaylist, hash, props) {
- this.data = props;
- this.hash = hash;
- this.hashInPlaylist = hashInPlaylist;
- this.type = props.type;
- this.title = props.title;
- this.text = props.text;
- this.creator = props.creator;
- this.file = props.file;
- this.thumb = props.thumb;
- if (props.date) {
- this.date = new Date(props.date);
- }
- else {
- this.date = new Date();
- }
- 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 = 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];
- this.relTarget = this.allLinks.reduce((accum, link) => {
- accum[link.rel] = link.target;
- return accum;
- }, {});
- 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
|