Working recently edited list

This commit is contained in:
Tom Moor
2017-11-19 21:32:18 -08:00
parent dc242038ff
commit 81edb55d56
7 changed files with 49 additions and 9 deletions

View File

@@ -96,7 +96,7 @@ class CollectionsStore {
const res = await this.client.post('/collections.list');
invariant(res && res.data, 'Collection list not available');
const { data } = res;
runInAction('CollectionsStore#fetch', () => {
runInAction('CollectionsStore#fetchAll', () => {
data.forEach(collection => {
this.data.set(collection.id, new Collection(collection));
});

View File

@@ -52,6 +52,17 @@ class DocumentsStore extends BaseStore {
return _.take(_.orderBy(this.data.values(), 'updatedAt', 'desc'), 5);
}
recentlyEditedInCollection(collectionId: string): Array<Document> {
return _.orderBy(
_.filter(
this.data.values(),
document => document.collectionId === collectionId
),
'updatedAt',
'desc'
);
}
@computed
get starred(): Array<Document> {
return _.filter(this.data.values(), 'starred');