diff --git a/apps/admin-x-settings/src/components/selectors/UnsplashSelector.tsx b/apps/admin-x-settings/src/components/selectors/UnsplashSelector.tsx index f016fc3d54..f4c4cbe6c2 100644 --- a/apps/admin-x-settings/src/components/selectors/UnsplashSelector.tsx +++ b/apps/admin-x-settings/src/components/selectors/UnsplashSelector.tsx @@ -1,6 +1,7 @@ import '@tryghost/unsplash-selector/styles/index.css'; import Portal from '../../utils/portal'; -import {DefaultHeaderTypes, PhotoType, UnsplashSearchModal} from '@tryghost/unsplash-selector'; +import {DefaultHeaderTypes, PhotoType, UnsplashProvider, UnsplashSearchModal} from '@tryghost/unsplash-selector'; +import {useMemo} from 'react'; interface UnsplashModalProps { onClose: () => void; @@ -8,13 +9,17 @@ interface UnsplashModalProps { unsplashConf: { defaultHeaders: DefaultHeaderTypes; }; + } export const UnsplashSelector : React.FC = ({onClose, onImageInsert, unsplashConf}) => { + const providerUnsplash = useMemo(() => { + return new UnsplashProvider(unsplashConf.defaultHeaders); + }, [unsplashConf]); return ( diff --git a/apps/unsplash-selector/src/api/InMemoryUnsplashProvider.ts b/apps/unsplash-selector/src/api/InMemoryUnsplashProvider.ts index c37c7c6311..ddb4d36207 100644 --- a/apps/unsplash-selector/src/api/InMemoryUnsplashProvider.ts +++ b/apps/unsplash-selector/src/api/InMemoryUnsplashProvider.ts @@ -40,7 +40,6 @@ export class InMemoryUnsplashProvider implements IUnsplashProvider { (photo.alt_description && photo.alt_description.toLowerCase().includes(term.toLowerCase())) ); this.SEARCH_IS_RUNNING = false; - return filteredPhotos; } diff --git a/apps/unsplash-selector/src/index.ts b/apps/unsplash-selector/src/index.ts index 3162cdbff4..91c0b1c449 100644 --- a/apps/unsplash-selector/src/index.ts +++ b/apps/unsplash-selector/src/index.ts @@ -1,3 +1,4 @@ export {default as UnsplashSearchModal} from './UnsplashSearchModal'; export type {DefaultHeaderTypes, Photo as PhotoType} from './UnsplashTypes'; +export {UnsplashProvider} from './api/UnsplashProvider'; import './styles/index.css'; \ No newline at end of file