Skip to content

useCollageDetails Composable ​

File Information ​

  • Path: app/composables/core/pages/useCollageDetails.ts
  • Purpose: Collage details page logic and asset management
  • Type: Core Composable

Overview ​

Collage details page logic and asset management

Features ​

Invalid or missing collage handling (ee26b58) ​

Mount order (onMounted):

  1. isValidResourceId(route.params.id) fails: snackbar.showError("Collage not found."), navigateTo('/<brand_name>/collage', { replace: true }), stop.
  2. Set collageParams to { page: 1, url_workspace_id, total_record: 36, sort_value, sort_by }, wait a tick.
  3. Only if collageDetailsQuery.data has no cached value: await loadCollageAssets("onload"); if it returns false, stop. With a cached value, the query watcher fills the page and no fetch is made here.
  4. fetchSearchData(), then register the mittBus download listeners (download-all-folder, download-file-collage, ...).

loadCollageAssets(flag = "default") now returns Promise<boolean>:

CaseResult
route.params.id fails isValidResourceIdfalse, no request
Request succeedstrue
Request fails on the initial load ("onload") with API code === 402 or a message matching /not found/isnackbar "Collage not found.", navigateTo('/<brand_name>/collage', { replace: true }), false
Request fails on the initial load for another reasoncollageNotFound = true (in-page empty state), false
Request fails on a later page or sortfalse, no redirect

The error code is read from error.data.code, then error.response._data.code, then error.code; the message the same way. Because onMounted stops on false, a failed initial load no longer goes on to call fetchSearchData() or register listeners for a page that has no collage.

Snackbars with the same text are de-duplicated by the snackbar plugin, so both paths showing "Collage not found." do not stack.

Sorting a fully loaded collage (PR #137) ​

loadCollageAssets returns true early when a page load is running (loadMore) or currentPage >= lastPage, except for a sort (flag === "sort" with sort_loader set). Before PR #137 the sort check came after this guard, so sorting a collage whose pages were all loaded did nothing.

MemberBehaviour
galleryDialog, galleryStartIdOpen state and asset to show first
galleryAssetscomputed over a swappable source function
galleryPaginationGalleryPagination or null
openGallery(file)Source = live displayFiles without parent_id; pagination = null during inner search, else { fetchPage: fetchGalleryPage, loadedPages: max(currentPage, 1), lastPage, total: assetList.assets_id.length }; starts at file.id
openGalleryForSelection()Snapshot of loaded selected rows (returns if empty), starts at the first. Without select-all or during search: no pagination. With select-all: fetchPage keeps only ids in selectedItemAssets, total = their count
closeGallery()Closes and clears galleryStartId

fetchGalleryPage(page) calls queryClient.fetchQuery with queryKeys.collections.details(collectionId, params) and collectionApi.getCollageDetails, params { page, url_workspace_id, total_record: COLLAGE_ASSETS_PER_PAGE (36), sort_value, sort_by }, and returns { items: assets.data, total: assetList.assets_id.length, lastPage: assets.last_page }. See Asset Management - Gallery Quick View.

Return Type ​

Refer to the composable source code for return type definitions. Composables use TypeScript for type-safe return values.

Parameters ​

Refer to the composable source code for parameter definitions. Composables use TypeScript for type-safe parameters.

Usage Example ​

typescript
import { useCollageDetails } from '~/composables/core/pages/useCollageDetails'

const { /* destructured return values */ } = useCollageDetails()