Skip to content

useFolderDetails Composable ​

File Information ​

  • Path: app/composables/core/pages/useFolderDetails.ts
  • Purpose: Folder details page logic and asset display
  • Type: Core Composable

Overview ​

Folder details page logic and asset display

Features ​

Invalid or missing folder handling (ee26b58) ​

Mount order (onMounted):

  1. isValidResourceId(route.params.id) fails: snackbar.showError("Folder not found."), navigateTo('/<brand_name>/folders', { replace: true }), stop.
  2. Wait a tick, reset pagination (currentPage = 0, lastPage = 1) and clear folder filters with store.updateFolderAllFilterList([]).
  3. If workspaceId is still empty, wait 200 ms once.
  4. await fetchFolder(); if it returns false, stop.
  5. fetchSearchData(), useSidebarCurrentFolder().setCurrentFolder(folder), emit current-folder on mittBus, then register the download listeners.

fetchFolder(flag = "no-sort") now returns Promise<boolean>:

CaseResult
route.params.id fails isValidResourceIdfalse, no request
Request succeedstrue
Request fails with flag "no-sort" (initial load and infinite-scroll pages) with API code === 402 or a message matching /not found/isnackbar "Folder not found.", navigateTo('/<brand_name>/folders', { replace: true }), false
Request fails with flag "no-sort" for another reasonfolderNotFound = true (in-page empty state), false
Request fails with a sort flagfalse, 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 folder.

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

Every folder load stores data.totalCounts.assets in folderAssetsTotal (assets only, folders excluded).

MemberBehaviour
galleryDialog, galleryStartId, galleryAssets, galleryPaginationSame shape as in useCollageDetails
openGallery(file)Source = live displayFiles without parent_id; pagination = null during inner search, else { fetchPage: fetchGalleryPage, loadedPages: max(currentPage, 1), lastPage, total: folderAssetsTotal }
openGalleryForSelection()Snapshot of loaded selected rows without parent_id (returns if empty), starts at the first. Without select-all or during search: no pagination. With select-all: see below
closeGallery()Closes and clears galleryStartId

Select-all selection: unticked loaded asset rows form deselectedIds. If folderAssetsTotal is larger than the number of loaded asset rows, any asset not in deselectedIds is selected and the total is max(0, folderAssetsTotal - deselectedIds.size); otherwise the selection is selectedItemAssets minus deselectedIds.

fetchGalleryPage(page) calls queryClient.fetchQuery with queryKeys.folderDetails.details(params) and foldersApi.fetchFolderDetails, params { sort_value, sort_by, workspace_id, category_id: route.params.id, page, total_record: 36 }, drops rows with parent_id, and returns { items, total: totalCounts.assets ?? folderAssetsTotal, lastPage: assets_with_folder.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 { useFolderDetails } from '~/composables/core/pages/useFolderDetails'

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