Skip to content
Snippets Groups Projects
Select Git revision
  • b4b4439a012433661f4b4f3f6fe9eef4731ca268
  • main default
  • 35-cgu
  • 34-peertube-support
  • 27-add-autoplay-to-iframe
  • 33-bug-on-youtube-embed-urls
  • RC-Rekall-v1.1-fix_lpo
  • tuleap-140-go-back-to-my-capsules-page-when-i-m-on-capsule-preview-page
  • RC-Rekall-v1.2-fix10
  • RC-Rekall-v1.2-fix9
  • RC-Rekall-v1.2-fix8
  • RC-Rekall-v1.2-fix7
  • RC-Rekall-v1.2-fix6
  • RC-Rekall-v1.2-fix5
  • RC-Rekall-v1.2-fix4
  • RC-Rekall-v1.2-fix3
  • RC-Rekall-v1.2-fix2
  • RC-Rekall-v1.2-fix1
  • RC-Rekall-v1.1-fix-3
  • RC-Rekall-v1.1-fix-2
  • RC-Rekall-v1.1-fix-1
  • RC-Rekall-v1.1-delivered
  • preprod20220209-1535
23 results

index.html

Blame
  • app.js 1.79 KiB
    import {
      all, call, put, takeEvery,
    } from 'redux-saga/effects';
    import { v4 as uuid } from 'uuid';
    import { fetchManifests } from './iiif';
    import { fetchWindowManifest } from './windows';
    import { addWindow } from '../actions';
    import ActionTypes from '../actions/action-types';
    
    /** */
    export function* importState(action) {
      yield all([
        ...Object.entries(action.state.windows || {})
          .map(([_, window]) => call(fetchWindowManifest, { id: window.id, payload: window })),
        ...Object.entries(action.state.manifests || {})
          .filter(([_, manifest]) => !manifest.json)
          .map(([_, manifest]) => call(fetchManifests, manifest.id)),
      ]);
    }
    
    /** Add windows from the imported config */
    export function* importConfig({ config: { thumbnailNavigation, windows } }) {
      if (!windows || windows.length === 0) return;
    
      const thunks = yield all(
        windows.map((miradorWindow) => {
          const windowId = `window-${uuid()}`;
          const manifestId = miradorWindow.manifestId || miradorWindow.loadedManifest;
    
          return call(addWindow, {
            // these are default values ...
            id: windowId,
            manifestId,
            thumbnailNavigationPosition: thumbnailNavigation && thumbnailNavigation.defaultPosition,
            // ... overridden by values from the window configuration ...
            ...miradorWindow,
          });
        }),
      );
    
      yield all(thunks.map(thunk => put(thunk)));
    }
    
    /** */
    export function* fetchCollectionManifests(action) {
      const { collectionPath, manifestId } = action;
      yield call(fetchManifests, manifestId, ...collectionPath);
    }
    
    /** */
    export default function* appSaga() {
      yield all([
        takeEvery(ActionTypes.IMPORT_MIRADOR_STATE, importState),
        takeEvery(ActionTypes.IMPORT_CONFIG, importConfig),
        takeEvery(ActionTypes.SHOW_COLLECTION_DIALOG, fetchCollectionManifests),
      ]);
    }