Skip to content

useSearchLibraryItems Composable ​

File Information ​

  • Path: app/composables/core/components/search/useSearchLibraryItems.ts
  • Purpose: Open, share, download and analytics logic for collage and folder search results rendered by SearchLibraryItems
  • Type: Core Composable (Search Component)

Overview ​

Exports the SearchLibraryType type ('collages' | 'folders') and the useSearchLibraryItems(props) composable.

  • Open: open(item) tracks the click, logs a viewed activity (collage with collection_id, or folder with category_id, environment: 'dealer'), resolves brand_name-collage-id or brand_name-folders-id and opens it in a new tab.
  • Grid card clicks: onCardClick(item, event) only records the search-result click; it ignores clicks inside .optionIcon, .menu-list, .v-checkbox or .search-matches.
  • Analytics source: 'overlay' when flag === 'search-bar', otherwise 'search-page', passed to trackSearchResultClick from useAmplitudeSearchTracking.
  • Count label: collages show Empty Collage or N Asset(s); folders show Empty Folder or N Subfolder(s), N Asset(s) (numbers formatted with en-US locale).
  • Share: shareCollage(item) opens the share dialog only when item.assets_count > 0; shareFolder(item) always opens it with the folder as the single item.
  • Download: downloadFolder(item) calls downloadStore.downloadMultipleFiles({ files: [], folders: [id], download_name: item.folder_name }), tracks a folder downloaded activity, and keeps the id in a downloading set until the download-all-folder mitt event fires (or the request fails).

Parameters ​

NameTypeDescription
props.typeSearchLibraryTypeResult type
props.itemsany[]Result entries
props.flag'search-bar' | 'results-page'Mount location
props.matchColumnboolean | null (optional)Overrides hasMatchColumn when not null/undefined

Return Type ​

KeyDescription
open(item)Track and open the collage/folder in a new tab
onCardClick(item, event)Track a grid card click on its open area
itemName(item)item.name || item.collection_name for collages, item.folder_name for folders
countLabel(item)Count text described above
formatDateUnixRe-exported from useHelpers()
hasMatchColumnprops.matchColumn ?? items.some(item => itemSearchMatches(item).length > 0): the caller's value wins; otherwise true when any item has matches beyond its name
shareDialog, shareCollageItem, shareCollageCollage share dialog state
shareFolderItems, shareFolder, shareFolderTitle, shareFolderDescriptionFolder share dialog state
isDownloading(item), downloadFolder(item)Folder download state and action

Usage ​

typescript
const { open, itemName, countLabel, downloadFolder } = useSearchLibraryItems(props)