← All changes
|
src/QuickEdit/components/modals/UnsplashImagePickerModal.jsx
+5
-10
3.1.1
→
3.2.1
View file →
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | import { downloadImage } from '@shared/api/wp'; |
| 2 | +import { resolveImageSearch } from '@shared/lib/image-search-defaults'; | |
| 3 | +import { track } from '@shared/lib/track'; | |
| 2 | 4 | import { fetchImages } from '@shared/lib/unsplash'; |
| 3 | 5 | import { |
| 4 | 6 | Button, |
| 5 | 7 | Modal, |
| @@ -12,9 +14,8 @@ | ||
| 12 | 14 | import { loadProduct, save, saveProduct } from '../../lib/api'; |
| 13 | 15 | import { invalidateBlockSource } from '../../lib/block-source-cache'; |
| 14 | 16 | import { splice } from '../../lib/dom'; |
| 15 | 17 | import { friendlyMessage } from '../../lib/errors'; |
| 16 | -import { track } from '../../lib/insights'; | |
| 17 | 18 | import { QE_MODAL_BODY_OPEN_CLASS } from '../../lib/modal-root'; |
| 18 | 19 | import { pushUndo } from '../../state/undo'; |
| 19 | 20 | import { ModalCloseButton } from './ModalCloseButton'; |
| 20 | 21 | |
| @@ -74,17 +75,11 @@ | ||
| 74 | 75 | useEffect(() => { |
| 75 | 76 | const ac = new AbortController(); |
| 76 | 77 | setLoadError(null); |
| 77 | 78 | setImages(null); |
| 78 | - // Empty search → seed from the site profile's first imageSearchTerm. | |
| 79 | - // We deliberately don't read from the Shared Unsplash cache: that's | |
| 80 | - // populated via `source='prefetch'`, which the backend serves at | |
| 81 | - // smaller dimensions for localStorage friendliness. A direct fetch | |
| 82 | - // with `source='user'` gives the same site-relevance signal with | |
| 83 | - // grid-thumbnail quality on par with searched results. | |
| 84 | - const seed = window.extSharedData?.siteProfile?.imageSearchTerms?.[0]; | |
| 85 | - const query = debounced || seed || 'unsplash'; | |
| 86 | - fetchImages(query, 'user') | |
| 79 | + // Not the shared prefetch cache: it holds a mix of every profile term, | |
| 80 | + // where one resolved term keeps the grid on a single subject. | |
| 81 | + fetchImages(resolveImageSearch(debounced), 'user') | |
| 87 | 82 | .then((res) => { |
| 88 | 83 | if (ac.signal.aborted) return; |
| 89 | 84 | setImages(res || []); |
| 90 | 85 | }) |