feat: Add includePublic parameter to getAssetsByTag API

- Add optional includePublic parameter (defaults to true) to getAssetsByTag
- Exclude public assets for media assets in sidebar by passing false
- Use URLSearchParams for cleaner query string construction

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jin Yi
2025-10-22 11:35:50 +09:00
parent 198bacc762
commit cd96b5147d
2 changed files with 13 additions and 3 deletions

View File

@@ -31,7 +31,7 @@ export function useAssetsApi() {
try {
// For input directory, just return assets without history
if (directory === 'input') {
const assets = await assetService.getAssetsByTag(directory)
const assets = await assetService.getAssetsByTag(directory, false)
// Process assets to truncate long filenames for display
return assets.map((asset) => ({
...asset,

View File

@@ -190,11 +190,21 @@ function createAssetService() {
* Gets assets filtered by a specific tag
*
* @param tag - The tag to filter by (e.g., 'models')
* @param includePublic - Whether to include public assets (default: true)
* @returns Promise<AssetItem[]> - Full asset objects filtered by tag, excluding missing assets
*/
async function getAssetsByTag(tag: string): Promise<AssetItem[]> {
async function getAssetsByTag(
tag: string,
includePublic: boolean = true
): Promise<AssetItem[]> {
const queryParams = new URLSearchParams({
include_tags: tag,
limit: DEFAULT_LIMIT.toString(),
include_public: includePublic ? 'true' : 'false'
})
const data = await handleAssetRequest(
`${ASSETS_ENDPOINT}?include_tags=${tag}&limit=${DEFAULT_LIMIT}`,
`${ASSETS_ENDPOINT}?${queryParams.toString()}`,
`assets for tag ${tag}`
)