Skip to content
Snippets Groups Projects
Commit 3c4d2b2d authored by Chris Beer's avatar Chris Beer Committed by Jack Reed
Browse files

Eager-load collection data when adding new windows

parent dbe5ab27
No related branches found
No related tags found
No related merge requests found
...@@ -65,6 +65,7 @@ describe('window-level sagas', () => { ...@@ -65,6 +65,7 @@ describe('window-level sagas', () => {
[select(getManifests), { 'manifest.json': {} }], [select(getManifests), { 'manifest.json': {} }],
[call(setWindowStartingCanvas, action)], [call(setWindowStartingCanvas, action)],
[call(setWindowDefaultSearchQuery, action)], [call(setWindowDefaultSearchQuery, action)],
[call(setCollectionPath, { manifestId: 'manifest.json', windowId: 'x' })],
]) ])
.call(setWindowStartingCanvas, action) .call(setWindowStartingCanvas, action)
.call(setWindowDefaultSearchQuery, action) .call(setWindowDefaultSearchQuery, action)
......
...@@ -43,6 +43,23 @@ export function* fetchWindowManifest(action) { ...@@ -43,6 +43,23 @@ export function* fetchWindowManifest(action) {
yield call(setWindowStartingCanvas, action); yield call(setWindowStartingCanvas, action);
yield call(setWindowDefaultSearchQuery, action); yield call(setWindowDefaultSearchQuery, action);
if (!collectionPath) {
yield call(setCollectionPath, { manifestId, windowId: action.id || action.window.id });
}
}
/** */
export function* setCollectionPath({ manifestId, windowId }) {
const manifestoInstance = yield select(getManifestoInstance, { manifestId });
if (manifestoInstance) {
const partOfs = manifestoInstance.getProperty('partOf');
const partOf = Array.isArray(partOfs) ? partOfs[0] : partOfs;
if (partOf && partOf.id) {
yield put(updateWindow(windowId, { collectionPath: [partOf.id] }));
}
}
} }
/** */ /** */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment