Skip to content

Commit

Permalink
BUGFIX: Make sure to have the latest content when switching pages
Browse files Browse the repository at this point in the history
This prevents showing outdated content, as the guest frame will not load new content by itself anymore.
  • Loading branch information
Sebobo committed Aug 8, 2024
1 parent 0d39c2e commit f4520af
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions packages/neos-ui-sagas/src/UI/ContentTree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,30 +141,23 @@ export function * watchCurrentDocument({globalRegistry, configuration}) {
return;
}

const state = yield select();
const childrenAreFullyLoaded = $get(['cr', 'nodes', 'byContextPath', contextPath, 'children'], state)
.filter(childEnvelope => nodeTypesRegistry.hasRole(childEnvelope.nodeType, 'content') || nodeTypesRegistry.hasRole(childEnvelope.nodeType, 'contentCollection'))
.every(
childEnvelope => Boolean($get(['cr', 'nodes', 'byContextPath', $get('contextPath', childEnvelope)], state))
);

if (!childrenAreFullyLoaded) {
yield put(actions.UI.ContentTree.setAsLoading(contextPath));

const nodeTypeFilter = `${nodeTypesRegistry.getRole('contentCollection')},${nodeTypesRegistry.getRole('content')}`;
const nodes = yield q([contextPath]).neosUiDefaultNodes(
nodeTypeFilter,
configuration.structureTree.loadingDepth,
[],
[]
).get();
const nodeMap = nodes.reduce((nodeMap, node) => {
nodeMap[$get('contextPath', node)] = node;
return nodeMap;
}, {});
// Always reload the nodes for the current page, when the document node changes.
// In the past, the guest frame loaded the latest nodedata from the rendered content, but this has been removed.
yield put(actions.UI.ContentTree.setAsLoading(contextPath));

yield put(actions.CR.Nodes.merge(nodeMap));
yield put(actions.UI.ContentTree.setAsLoaded(contextPath));
}
const nodeTypeFilter = `${nodeTypesRegistry.getRole('contentCollection')},${nodeTypesRegistry.getRole('content')}`;
const nodes = yield q([contextPath]).neosUiDefaultNodes(
nodeTypeFilter,
configuration.structureTree.loadingDepth,
[],
[]
).get();
const nodeMap = nodes.reduce((nodeMap, node) => {
nodeMap[$get('contextPath', node)] = node;
return nodeMap;
}, {});

yield put(actions.CR.Nodes.merge(nodeMap));
yield put(actions.UI.ContentTree.setAsLoaded(contextPath));
});
}

0 comments on commit f4520af

Please sign in to comment.