From 24e68d8ed8c8c3766765cf2743151ff5af55ff61 Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Fri, 30 Sep 2022 18:18:02 -0400 Subject: [PATCH] Properly load entries when switching collections --- package.json | 2 +- src/components/Collection/Collection.tsx | 7 ++++++- src/components/Collection/Entries/EntriesCollection.js | 2 +- website/content/docs/beta-features.md | 2 +- website/src/components/event-box.js | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index bb6bd09b..e129f323 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@simplecms/simple-cms-core", - "version": "0.1.2", + "version": "0.1.3", "license": "MIT", "description": "Simple CMS core application.", "repository": "https://github.com/SimpleCMS/simple-cms", diff --git a/src/components/Collection/Collection.tsx b/src/components/Collection/Collection.tsx index aad9ec6a..ebb3da1d 100644 --- a/src/components/Collection/Collection.tsx +++ b/src/components/Collection/Collection.tsx @@ -104,7 +104,12 @@ const CollectionView = ({ const renderEntriesCollection = useCallback(() => { return ( - + ); }, [collection, filterTerm, viewStyle, readyToLoad]); diff --git a/src/components/Collection/Entries/EntriesCollection.js b/src/components/Collection/Entries/EntriesCollection.js index 49e098be..0df30d4c 100644 --- a/src/components/Collection/Entries/EntriesCollection.js +++ b/src/components/Collection/Entries/EntriesCollection.js @@ -80,7 +80,7 @@ class EntriesCollection extends React.Component { componentDidUpdate(prevProps) { const { collection, entriesLoaded, loadEntries, readyToLoad } = this.props; - if (!entriesLoaded && readyToLoad && !prevProps.readyToLoad) { + if (!entriesLoaded && readyToLoad && (!prevProps.readyToLoad || prevProps.collection !== collection)) { loadEntries(collection); } } diff --git a/website/content/docs/beta-features.md b/website/content/docs/beta-features.md index c635c299..912df561 100644 --- a/website/content/docs/beta-features.md +++ b/website/content/docs/beta-features.md @@ -571,7 +571,7 @@ Example usage: ```javascript CMS.registerEventListener({ name: 'prePublish', - handler: ({ author, entry }) => console.log(JSON.stringify({ author, data: entry.get('data') })), + handler: ({ author, entry }) => console.info(JSON.stringify({ author, data: entry.get('data') })), }); ``` diff --git a/website/src/components/event-box.js b/website/src/components/event-box.js index 24b1abc3..b03403d4 100644 --- a/website/src/components/event-box.js +++ b/website/src/components/event-box.js @@ -82,7 +82,7 @@ function EventBox({ title, cta }) { setLoading(false); }) .catch(err => { - console.log(err); // eslint-disable-line no-console + console.error(err); // eslint-disable-line no-console // TODO: set state to show error message setLoading(false);