Filter out directories from file picker, show only files
- Filter git files ending with / (directories) - Filter search results ending with / (directories) - Only show actual files in file picker - Directories cannot be attached as files
This commit is contained in:
@@ -48,12 +48,14 @@ const FilePicker: Component<FilePickerProps> = (props) => {
|
|||||||
console.log(`[FilePicker] Git files response received in ${elapsed}ms:`, gitResponse)
|
console.log(`[FilePicker] Git files response received in ${elapsed}ms:`, gitResponse)
|
||||||
|
|
||||||
if (gitResponse?.data && gitResponse.data.length > 0) {
|
if (gitResponse?.data && gitResponse.data.length > 0) {
|
||||||
const gitFiles: FileItem[] = gitResponse.data.map((file: any) => ({
|
const gitFiles: FileItem[] = gitResponse.data
|
||||||
path: file.path,
|
.filter((file: any) => !file.path.endsWith("/"))
|
||||||
added: file.added,
|
.map((file: any) => ({
|
||||||
removed: file.removed,
|
path: file.path,
|
||||||
isGitFile: true,
|
added: file.added,
|
||||||
}))
|
removed: file.removed,
|
||||||
|
isGitFile: true,
|
||||||
|
}))
|
||||||
console.log(`[FilePicker] Cached ${gitFiles.length} git files`)
|
console.log(`[FilePicker] Cached ${gitFiles.length} git files`)
|
||||||
setCachedGitFiles(gitFiles)
|
setCachedGitFiles(gitFiles)
|
||||||
} else {
|
} else {
|
||||||
@@ -91,6 +93,7 @@ const FilePicker: Component<FilePickerProps> = (props) => {
|
|||||||
console.log(`[FilePicker] Search response received in ${elapsed}ms:`, searchResponse)
|
console.log(`[FilePicker] Search response received in ${elapsed}ms:`, searchResponse)
|
||||||
|
|
||||||
searchFiles = (searchResponse?.data || [])
|
searchFiles = (searchResponse?.data || [])
|
||||||
|
.filter((path: string) => !path.endsWith("/"))
|
||||||
.filter((path: string) => !gitFiles.some((gf) => gf.path === path))
|
.filter((path: string) => !gitFiles.some((gf) => gf.path === path))
|
||||||
.map((path: string) => ({
|
.map((path: string) => ({
|
||||||
path,
|
path,
|
||||||
@@ -106,6 +109,7 @@ const FilePicker: Component<FilePickerProps> = (props) => {
|
|||||||
console.log(`[FilePicker] All files response received in ${elapsed}ms:`, searchResponse)
|
console.log(`[FilePicker] All files response received in ${elapsed}ms:`, searchResponse)
|
||||||
|
|
||||||
searchFiles = (searchResponse?.data || [])
|
searchFiles = (searchResponse?.data || [])
|
||||||
|
.filter((path: string) => !path.endsWith("/"))
|
||||||
.filter((path: string) => !gitFiles.some((gf) => gf.path === path))
|
.filter((path: string) => !gitFiles.some((gf) => gf.path === path))
|
||||||
.map((path: string) => ({
|
.map((path: string) => ({
|
||||||
path,
|
path,
|
||||||
|
|||||||
Reference in New Issue
Block a user