diff --git a/src/components/CollectionDialog.js b/src/components/CollectionDialog.js index 9c92b5e4d43b480e215e070de6d583e4ef03c4f4..53e65d67117f2b899e2535677041313eb3fedd71 100644 --- a/src/components/CollectionDialog.js +++ b/src/components/CollectionDialog.js @@ -13,21 +13,12 @@ import { } from '@material-ui/core'; import ArrowBackIcon from '@material-ui/icons/ArrowBackSharp'; import Skeleton from '@material-ui/lab/Skeleton'; +import asArray from '../lib/asArray'; import { LabelValueMetadata } from './LabelValueMetadata'; import CollapsibleSection from '../containers/CollapsibleSection'; import ScrollIndicatedDialogContent from '../containers/ScrollIndicatedDialogContent'; import ManifestInfo from '../containers/ManifestInfo'; -/** - */ -function asArray(value) { - if (!Array.isArray(value)) { - return [value]; - } - - return value; -} - /** * a dialog providing the possibility to select the collection */ diff --git a/src/lib/ThumbnailFactory.js b/src/lib/ThumbnailFactory.js index 67f8a5787467a7b7ce3d008508337b6690364492..79c063f8852c82b9044640ed28e33d25b8e6de3d 100644 --- a/src/lib/ThumbnailFactory.js +++ b/src/lib/ThumbnailFactory.js @@ -1,12 +1,7 @@ import { Utils } from 'manifesto.js'; import MiradorManifest from './MiradorManifest'; import MiradorCanvas from './MiradorCanvas'; - -/** */ -function asArray(value) { - if (value === undefined) return []; - return Array.isArray(value) ? value : [value]; -} +import asArray from './asArray'; /** */ function isLevel0ImageProfile(service) { diff --git a/src/lib/asArray.js b/src/lib/asArray.js new file mode 100644 index 0000000000000000000000000000000000000000..31557e924d1af3aa5fa01992f46470259f79bfac --- /dev/null +++ b/src/lib/asArray.js @@ -0,0 +1,11 @@ +/** + */ +export default function asArray(value) { + if (value === undefined) return []; + + if (!Array.isArray(value)) { + return [value]; + } + + return value; +} diff --git a/src/state/selectors/manifests.js b/src/state/selectors/manifests.js index e9d7c2bbcb13036f2ed27be1abb280a90750a2c7..44add0908978d8007489745d19ef966257666df9 100644 --- a/src/state/selectors/manifests.js +++ b/src/state/selectors/manifests.js @@ -3,6 +3,7 @@ import createCachedSelector from 're-reselect'; import { PropertyValue } from 'manifesto.js/dist-esmodule/PropertyValue'; import { Utils } from 'manifesto.js/dist-esmodule/Utils'; import getThumbnail from '../../lib/ThumbnailFactory'; +import asArray from '../../lib/asArray'; import { getCompanionWindow } from './companionWindows'; import { getManifest } from './getters'; import { getConfig } from './config'; @@ -109,16 +110,6 @@ export const getManifestProvider = createSelector( && PropertyValue.parse(provider[0].label, locale).getValue(), ); -/** - */ -function asArray(value) { - if (!Array.isArray(value)) { - return [value]; - } - - return value; -} - /** * Return the IIIF v3 homepage of a manifest or null * @param {object} state