Skip to content
Snippets Groups Projects
Commit 15047693 authored by Chris Beer's avatar Chris Beer
Browse files

Bookkeep the window that initiated a IIIF auth flow

parent 359063d4
No related branches found
No related tags found
No related merge requests found
......@@ -166,6 +166,7 @@ describe('IIIF sagas', () => {
const action = {
imageResource: {},
infoId: 'infoId',
windowId: 'window',
};
return expectSaga(fetchInfoResponse, action)
......@@ -175,6 +176,7 @@ describe('IIIF sagas', () => {
ok: true,
tokenServiceId: undefined,
type: 'mirador/RECEIVE_DEGRADED_INFO_RESPONSE',
windowId: 'window',
})
.run();
});
......
......@@ -6,11 +6,12 @@ import ActionTypes from './action-types';
* @param {String} infoId
* @memberof ActionCreators
*/
export function requestInfoResponse(infoId, imageResource) {
export function requestInfoResponse(infoId, imageResource, windowId) {
return {
imageResource,
infoId,
type: ActionTypes.REQUEST_INFO_RESPONSE,
windowId,
};
}
......@@ -38,13 +39,14 @@ export function receiveInfoResponse(infoId, infoJson, ok, tokenServiceId) {
* @param {Object} manifestJson
* @memberof ActionCreators
*/
export function receiveDegradedInfoResponse(infoId, infoJson, ok, tokenServiceId) {
export function receiveDegradedInfoResponse(infoId, infoJson, ok, tokenServiceId, windowId) {
return {
infoId,
infoJson,
ok,
tokenServiceId,
type: ActionTypes.RECEIVE_DEGRADED_INFO_RESPONSE,
windowId,
};
}
......@@ -70,10 +72,10 @@ export function receiveInfoResponseFailure(infoId, error, tokenServiceId) {
* @param {String} infoId
* @memberof ActionCreators
*/
export function fetchInfoResponse({ imageId, imageResource }) {
export function fetchInfoResponse({ imageId, imageResource, windowId }) {
const imageService = imageResource && imageResource.getServices()[0];
const infoId = (imageId || imageService.id);
return requestInfoResponse(infoId, imageService);
return requestInfoResponse(infoId, imageService, windowId);
}
/**
......
......@@ -132,7 +132,7 @@ function* getAccessTokenService(resource) {
}
/** @private */
export function* fetchInfoResponse({ imageResource, infoId, tokenService: passedTokenService }) {
export function* fetchInfoResponse({ imageResource, infoId, windowId }) {
let iiifResource = imageResource;
if (!iiifResource) {
iiifResource = yield select(selectInfoResponse, { infoId });
......@@ -141,7 +141,7 @@ export function* fetchInfoResponse({ imageResource, infoId, tokenService: passed
const callbacks = {
degraded: ({
json, response, tokenServiceId,
}) => receiveDegradedInfoResponse(infoId, json, response.ok, tokenServiceId),
}) => receiveDegradedInfoResponse(infoId, json, response.ok, tokenServiceId, windowId),
failure: ({
error, json, response, tokenServiceId,
}) => (
......
......@@ -223,7 +223,7 @@ export function* fetchInfoResponses({ visibleCanvases: visibleCanvasIds, windowI
const miradorCanvas = new MiradorCanvas(canvas);
return all(miradorCanvas.iiifImageResources.map(imageResource => (
!infoResponses[imageResource.getServices()[0].id]
&& put(fetchInfoResponse({ imageResource }))
&& put(fetchInfoResponse({ imageResource, windowId }))
)).filter(Boolean));
}));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment