Merge pull request #455 from outline/issue-collection-id

Fixes: Issue with missing collection id
This commit is contained in:
Tom Moor 2017-11-28 20:30:59 -08:00 committed by GitHub
commit 756cc5d3ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 7 deletions

View File

@ -44,6 +44,19 @@ class Collection extends BaseModel {
return this.documents.length === 0;
}
@computed
get documentIds(): string[] {
const results = [];
const travelDocuments = (documentList, path) =>
documentList.forEach(document => {
results.push(document.id);
travelDocuments(document.children);
});
travelDocuments(this.documents);
return results;
}
/* Actions */
@action

View File

@ -123,8 +123,8 @@ class CollectionScene extends Component {
</Heading>
<Subheading>Recently edited</Subheading>
<DocumentList
documents={this.props.documents.recentlyEditedInCollection(
this.collection.id
documents={this.props.documents.recentlyEditedIn(
this.collection.documentIds
)}
/>
<Actions align="center" justify="flex-end">

View File

@ -48,15 +48,14 @@ class DocumentsStore extends BaseStore {
}
@computed
get recentlyEdited(): Array<Document> {
get recentlyEdited(): Document[] {
return _.take(_.orderBy(this.data.values(), 'updatedAt', 'desc'), 5);
}
recentlyEditedInCollection(collectionId: string): Array<Document> {
recentlyEditedIn(documentIds: string[]): Document[] {
return _.orderBy(
_.filter(
this.data.values(),
document => document.collection.id === collectionId
_.filter(this.data.values(), document =>
documentIds.includes(document.id)
),
'updatedAt',
'desc'