Display document views (#849)

* Display who has viewed a document in the header

* Add overflow, display of WHEN last viewed
Cleanup old document attributes
Add firstViewedAt, lastViewedAt to API response

* Cleanup

* Added: API documentation for views endpoints

* Include views for deleted users
This commit is contained in:
Tom Moor
2019-01-08 22:49:20 -08:00
committed by GitHub
parent 11b0ac0c66
commit c78bf3c4bf
14 changed files with 216 additions and 123 deletions

View File

@ -1,5 +1,5 @@
// @flow
import { action, set, computed, observable } from 'mobx';
import { action, set, computed } from 'mobx';
import invariant from 'invariant';
import { client } from 'utils/ApiClient';
@ -22,7 +22,6 @@ export default class Document extends BaseModel {
collaborators: User[];
collection: Collection;
collectionId: string;
firstViewedAt: ?string;
lastViewedAt: ?string;
createdAt: string;
createdBy: User;
@ -40,9 +39,7 @@ export default class Document extends BaseModel {
url: string;
urlId: string;
shareUrl: ?string;
views: number;
revision: number;
@observable embedsDisabled: ?boolean;
constructor(data?: Object = {}, store: *) {
super(data, store);
@ -144,16 +141,6 @@ export default class Document extends BaseModel {
}
};
@action
enableEmbeds = () => {
this.embedsDisabled = false;
};
@action
disableEmbeds = () => {
this.embedsDisabled = true;
};
@action
star = async () => {
this.starred = true;
@ -178,8 +165,7 @@ export default class Document extends BaseModel {
@action
view = async () => {
this.views++;
await client.post('/views.create', { id: this.id });
await client.post('/views.create', { documentId: this.id });
};
@action