Appearance
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):
isValidResourceId(route.params.id)fails:snackbar.showError("Folder not found."),navigateTo('/<brand_name>/folders', { replace: true }), stop.- Wait a tick, reset pagination (
currentPage = 0,lastPage = 1) and clear folder filters withstore.updateFolderAllFilterList([]). - If
workspaceIdis still empty, wait 200 ms once. await fetchFolder(); if it returnsfalse, stop.fetchSearchData(),useSidebarCurrentFolder().setCurrentFolder(folder), emitcurrent-folderonmittBus, then register the download listeners.
fetchFolder(flag = "no-sort") now returns Promise<boolean>:
| Case | Result |
|---|---|
route.params.id fails isValidResourceId | false, no request |
| Request succeeds | true |
Request fails with flag "no-sort" (initial load and infinite-scroll pages) with API code === 402 or a message matching /not found/i | snackbar "Folder not found.", navigateTo('/<brand_name>/folders', { replace: true }), false |
Request fails with flag "no-sort" for another reason | folderNotFound = true (in-page empty state), false |
| Request fails with a sort flag | false, 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.
Gallery quick view (PR #137) ​
Every folder load stores data.totalCounts.assets in folderAssetsTotal (assets only, folders excluded).
| Member | Behaviour |
|---|---|
galleryDialog, galleryStartId, galleryAssets, galleryPagination | Same 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()Related Composables ​
- See Composables Overview for all composables
Related Documentation ​
- Composables Overview - All composables
- Types - TypeScript type definitions
- Components - Components using this composable