DocumentsStore WIP

This commit is contained in:
Tom Moor
2017-06-27 20:59:53 -07:00
parent f8a715dcef
commit 72fd39b494
8 changed files with 125 additions and 9 deletions

View File

@ -2,7 +2,7 @@
import { extendObservable, action, runInAction, computed } from 'mobx';
import invariant from 'invariant';
import ApiClient, { client } from 'utils/ApiClient';
import { client } from 'utils/ApiClient';
import stores from 'stores';
import ErrorsStore from 'stores/ErrorsStore';
@ -17,14 +17,13 @@ class Document {
html: string;
id: string;
private: boolean;
starred: boolean;
team: string;
text: string;
title: string;
updatedAt: string;
updatedBy: User;
url: string;
client: ApiClient;
errors: ErrorsStore;
/* Computed */
@ -56,7 +55,7 @@ class Document {
@action update = async () => {
try {
const res = await this.client.post('/documents.info', { id: this.id });
const res = await client.post('/documents.info', { id: this.id });
invariant(res && res.data, 'Document API response should be available');
const { data } = res;
runInAction('Document#update', () => {
@ -73,7 +72,6 @@ class Document {
constructor(document: Document) {
this.updateData(document);
this.client = client;
this.errors = stores.errors;
}
}