fixes: Document menu on search results is empty if not previously loaded

closes #1124
This commit is contained in:
Tom Moor
2019-12-23 17:59:15 -08:00
parent b6fd9f4211
commit 595cb9cda5

View File

@@ -293,15 +293,15 @@ export default class DocumentsStore extends BaseStore<Document> {
query,
});
invariant(res && res.data, 'Search response should be available');
const { data } = res;
// add the document to the store
data.forEach(result => this.add(result.document));
// add the documents and associated policies to the store
res.data.forEach(result => this.add(result.document));
this.addPolicies(res.policies);
// store a reference to the document model in the search cache instead
// of the original result from the API.
const results: SearchResult[] = compact(
data.map(result => {
res.data.map(result => {
const document = this.data.get(result.document.id);
if (!document) return null;