Properly load entries when switching collections
This commit is contained in:
parent
9bd6fb49d1
commit
24e68d8ed8
@ -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",
|
||||||
|
@ -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]);
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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') })),
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user