Properly load entries when switching collections

This commit is contained in:
Daniel Lautzenheiser 2022-09-30 18:18:02 -04:00
parent 9bd6fb49d1
commit 24e68d8ed8
5 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@simplecms/simple-cms-core", "name": "@simplecms/simple-cms-core",
"version": "0.1.2", "version": "0.1.3",
"license": "MIT", "license": "MIT",
"description": "Simple CMS core application.", "description": "Simple CMS core application.",
"repository": "https://github.com/SimpleCMS/simple-cms", "repository": "https://github.com/SimpleCMS/simple-cms",

View File

@ -104,7 +104,12 @@ const CollectionView = ({
const renderEntriesCollection = useCallback(() => { const renderEntriesCollection = useCallback(() => {
return ( return (
<EntriesCollection collection={collection} viewStyle={viewStyle} filterTerm={filterTerm} readyToLoad={readyToLoad} /> <EntriesCollection
collection={collection}
viewStyle={viewStyle}
filterTerm={filterTerm}
readyToLoad={readyToLoad}
/>
); );
}, [collection, filterTerm, viewStyle, readyToLoad]); }, [collection, filterTerm, viewStyle, readyToLoad]);

View File

@ -80,7 +80,7 @@ class EntriesCollection extends React.Component {
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
const { collection, entriesLoaded, loadEntries, readyToLoad } = this.props; const { collection, entriesLoaded, loadEntries, readyToLoad } = this.props;
if (!entriesLoaded && readyToLoad && !prevProps.readyToLoad) { if (!entriesLoaded && readyToLoad && (!prevProps.readyToLoad || prevProps.collection !== collection)) {
loadEntries(collection); loadEntries(collection);
} }
} }

View File

@ -571,7 +571,7 @@ Example usage:
```javascript ```javascript
CMS.registerEventListener({ CMS.registerEventListener({
name: 'prePublish', 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') })),
}); });
``` ```

View File

@ -82,7 +82,7 @@ function EventBox({ title, cta }) {
setLoading(false); setLoading(false);
}) })
.catch(err => { .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 // TODO: set state to show error message
setLoading(false); setLoading(false);