From 122f2b0e8b30a761c4705707f3eb9cd9111d1d1b Mon Sep 17 00:00:00 2001 From: Ilya Bondar Date: Mon, 16 Dec 2024 15:30:56 +0100 Subject: [PATCH] fix(chat): hide `clientdata` folder (Issue #2704) --- apps/chat/src/utils/app/data/file-service.ts | 57 +++++++++++--------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/apps/chat/src/utils/app/data/file-service.ts b/apps/chat/src/utils/app/data/file-service.ts index 7394dd986e..856e0e7403 100644 --- a/apps/chat/src/utils/app/data/file-service.ts +++ b/apps/chat/src/utils/app/data/file-service.ts @@ -10,6 +10,8 @@ import { import { FolderType } from '@/src/types/folder'; import { HTTPMethod } from '@/src/types/http'; +import { CLIENTDATA_PATH } from '@/src/constants/client-data'; + import { ApiUtils } from '../../server/api'; import { constructPath } from '../file'; import { getFileRootId } from '../id'; @@ -121,30 +123,37 @@ export class FileService { this.getListingUrl({ path: parentPath, resultQuery }), ).pipe( map((folders: BackendFileFolder[]) => { - return folders.map((folder): FileFolderInterface => { - const relativePath = folder.parentPath - ? ApiUtils.decodeApiUrl(folder.parentPath) - : undefined; - - return { - id: constructPath( - ApiKeys.Files, - folder.bucket, - relativePath, - folder.name, - ), - name: folder.name, - type: FolderType.File, - absolutePath: constructPath( - ApiKeys.Files, - folder.bucket, - relativePath, - ), - relativePath: relativePath, - folderId: constructPath(getFileRootId(folder.bucket), relativePath), - serverSynced: true, - }; - }); + return folders + .filter( + (folder) => !!folder.parentPath || folder.name !== CLIENTDATA_PATH, + ) + .map((folder): FileFolderInterface => { + const relativePath = folder.parentPath + ? ApiUtils.decodeApiUrl(folder.parentPath) + : undefined; + + return { + id: constructPath( + ApiKeys.Files, + folder.bucket, + relativePath, + folder.name, + ), + name: folder.name, + type: FolderType.File, + absolutePath: constructPath( + ApiKeys.Files, + folder.bucket, + relativePath, + ), + relativePath: relativePath, + folderId: constructPath( + getFileRootId(folder.bucket), + relativePath, + ), + serverSynced: true, + }; + }); }), ); }