Gen and copy share link from frontend

This commit is contained in:
Tom Moor
2018-05-16 23:07:33 -07:00
parent 500d039856
commit 4266020315
8 changed files with 94 additions and 6 deletions

View File

@@ -40,6 +40,7 @@ class Document extends BaseModel {
parentDocument: ?string;
publishedAt: ?string;
url: string;
shareUrl: ?string;
views: number;
revision: number;
@@ -101,6 +102,18 @@ class Document extends BaseModel {
/* Actions */
@action
share = async () => {
try {
const res = await client.post('/shares.create', { id: this.id });
invariant(res && res.data, 'Document API response should be available');
this.shareUrl = res.data.url;
} catch (e) {
this.errors.add('Document failed to share');
}
};
@action
pin = async () => {
this.pinned = true;