From 27f917275026b64e344767de60659d6859a6d8b8 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 17 Feb 2022 20:17:02 -0800 Subject: [PATCH] fix: Collection with only draft shows empty state, closes #3119 --- app/models/Collection.ts | 5 ++++- app/stores/DocumentsStore.ts | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/Collection.ts b/app/models/Collection.ts index ec22f5dc8..7761f1e24 100644 --- a/app/models/Collection.ts +++ b/app/models/Collection.ts @@ -66,7 +66,10 @@ export default class Collection extends BaseModel { @computed get isEmpty(): boolean { - return this.documents.length === 0; + return ( + this.documents.length === 0 && + this.store.rootStore.documents.inCollection(this.id).length === 0 + ); } @computed diff --git a/app/stores/DocumentsStore.ts b/app/stores/DocumentsStore.ts index f01c13058..b64f2dff8 100644 --- a/app/stores/DocumentsStore.ts +++ b/app/stores/DocumentsStore.ts @@ -142,7 +142,12 @@ export default class DocumentsStore extends BaseStore { return []; } - return compact(collection.documents.map((node) => this.get(node.id))); + const drafts = this.drafts({ collectionId }); + + return compact([ + ...drafts, + ...collection.documents.map((node) => this.get(node.id)), + ]); } leastRecentlyUpdatedInCollection(collectionId: string): Document[] {