diff options
| author | raku-cat <raku@raku.party> | 2018-12-27 03:22:36 -0600 |
|---|---|---|
| committer | Shyam Sunder <sgsunder1@gmail.com> | 2019-02-08 16:43:38 -0500 |
| commit | 3e6b98df92a9e723a7d1b33e28b7d6b057981783 (patch) | |
| tree | 32895b3c98d4556d8c4168bb1e40f0d92b883e2c /client/js/models | |
| parent | 2fdd8cb3ab4f45796a4e9dd858caaaf215d19ef3 (diff) | |
client: Reimplement post source functionality
Diffstat (limited to 'client/js/models')
| -rw-r--r-- | client/js/models/post.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/client/js/models/post.js b/client/js/models/post.js index aea8c4c..90ff300 100644 --- a/client/js/models/post.js +++ b/client/js/models/post.js @@ -32,6 +32,7 @@ class Post extends events.EventTarget { get contentUrl() { return this._contentUrl; } get fullContentUrl() { return this._fullContentUrl; } get thumbnailUrl() { return this._thumbnailUrl; } + get source() { return this._source; } get canvasWidth() { return this._canvasWidth || 800; } get canvasHeight() { return this._canvasHeight || 450; } get fileSize() { return this._fileSize || 0; } @@ -57,6 +58,7 @@ class Post extends events.EventTarget { set relations(value) { this._relations = value; } set newContent(value) { this._newContent = value; } set newThumbnail(value) { this._newThumbnail = value; } + set source(value) { this._source = value; } static fromResponse(response) { const ret = new Post(); @@ -122,6 +124,9 @@ class Post extends events.EventTarget { if (this._newThumbnail !== undefined) { files.thumbnail = this._newThumbnail; } + if (this._source !== this._orig._source) { + detail.source = this._source; + } let apiPromise = this._id ? api.put(uri.formatApiLink('post', this.id), detail, files) : @@ -266,6 +271,10 @@ class Post extends events.EventTarget { Math.round(Math.random() * 1000); } + prettyPrintSource() { + return uri.extractRootDomain(this._source); + } + _updateFromResponse(response) { const map = () => ({ _version: response.version, @@ -278,6 +287,7 @@ class Post extends events.EventTarget { _contentUrl: response.contentUrl, _fullContentUrl: new URL(response.contentUrl, document.getElementsByTagName('base')[0].href).href, _thumbnailUrl: response.thumbnailUrl, + _source: response.source, _canvasWidth: response.canvasWidth, _canvasHeight: response.canvasHeight, _fileSize: response.fileSize, |