UNPKG

weverse

Version:
34 lines (33 loc) 1.11 kB
import { AssignType, WeverseUrl as urls } from "../client"; import axios from 'axios'; export class WeversePost extends AssignType() { constructor(props, community, artist) { super(props); this.comments = []; this.artist = artist; this.community = community; } async getVideoUrls(headers) { if (this.attachedVideos) { const { data } = await axios.post(urls.postDetails(this.id, this.community.id), {}, { headers }); if (typeof data.attachedVideos[0].videoUrl === 'string') { this.attachedVideos[0].videoUrl = new URL(data.attachedVideos[0].videoUrl); } } else { return; } } addComments(comments) { const added = comments.filter(c => !this.comments.some(c2 => c2.id === c.id)); this.comments = added.concat(this.comments); return added; } toJSON() { const partial = Object.assign({}, this); delete partial.artist; delete partial.community; delete partial.comments; return partial; } }