|
1 | 1 | import { createSelector } from 'reselect'; |
2 | 2 | import { Utils } from 'manifesto.js'; |
3 | 3 | import flatten from 'lodash/flatten'; |
| 4 | +import { |
| 5 | + audioResourcesFrom, filterByTypes, textResourcesFrom, videoResourcesFrom, |
| 6 | +} from '../../lib/typeFilters'; |
4 | 7 | import MiradorCanvas from '../../lib/MiradorCanvas'; |
5 | 8 | import { miradorSlice } from './utils'; |
6 | 9 | import { getConfig } from './config'; |
@@ -48,15 +51,27 @@ export const selectCurrentAuthServices = createSelector( |
48 | 51 | })); |
49 | 52 | } |
50 | 53 |
|
| 54 | + if (currentAuthResources.length === 0 && canvases) { |
| 55 | + currentAuthResources = flatten(canvases.map(c => { |
| 56 | + const miradorCanvas = new MiradorCanvas(c); |
| 57 | + const canvasResources = miradorCanvas.imageResources; |
| 58 | + return videoResourcesFrom(canvasResources) |
| 59 | + .concat(audioResourcesFrom(canvasResources)) |
| 60 | + .concat(textResourcesFrom(canvasResources)); |
| 61 | + })); |
| 62 | + } |
| 63 | + |
51 | 64 | if (!currentAuthResources) return []; |
52 | 65 | if (currentAuthResources.length === 0) return []; |
53 | 66 |
|
54 | 67 | const currentAuthServices = currentAuthResources.map(resource => { |
55 | 68 | let lastAttemptedService; |
56 | | - const services = Utils.getServices(resource); |
| 69 | + const resourceServices = Utils.getServices(resource); |
| 70 | + const probeServices = filterByTypes(resourceServices, 'AuthProbeService2'); |
| 71 | + const probeServiceServices = flatten(probeServices.map(p => Utils.getServices(p))); |
57 | 72 |
|
58 | 73 | for (const authProfile of serviceProfiles) { |
59 | | - const profiledAuthServices = services.filter( |
| 74 | + const profiledAuthServices = resourceServices.concat(probeServiceServices).filter( |
60 | 75 | p => authProfile.profile === p.getProfile(), |
61 | 76 | ); |
62 | 77 |
|
|
0 commit comments