Skip to content

Commit 60e8e8f

Browse files
committed
fix(app-file-manager): use type_startsWith for asset filtering
1 parent bcac0a9 commit 60e8e8f

File tree

2 files changed

+15
-3
lines changed
  • packages/app-file-manager/src/modules

2 files changed

+15
-3
lines changed

packages/app-file-manager/src/modules/FileManagerApiProvider/graphql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export interface ListFilesWhereQueryVariables {
5353
tags_in?: string[];
5454
tags_startsWith?: string;
5555
tags_not_startsWith?: string;
56-
type_in?: string[];
5756
createdBy?: string;
5857
AND?: ListFilesWhereQueryVariables[];
58+
[key: string]: any;
5959
}
6060

6161
export interface ListFilesQueryVariables {

packages/app-file-manager/src/modules/FileManagerRenderer/FileManagerViewProvider/useListFiles.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ import { useFileManagerApi } from "~/modules/FileManagerApiProvider/FileManagerA
1616
import { getScopeWhereParams, State } from "./state";
1717
import { ROOT_FOLDER } from "~/constants";
1818

19+
const toTypeInput = (value: string) => {
20+
return value.replace("*", "");
21+
};
22+
1923
function nonEmptyArray(value: string[] | undefined, fallback: string[] | undefined = undefined) {
2024
if (Array.isArray(value)) {
21-
return value.length ? value : undefined;
25+
return value.length ? value.map(toTypeInput) : undefined;
2226
}
2327

2428
return fallback;
@@ -98,6 +102,15 @@ export function useListFiles({ modifiers, folderId, state }: UseListFilesParams)
98102

99103
const AND: ListFilesWhereQueryVariables[] = [];
100104

105+
if (modifiers.accept.length) {
106+
const types = nonEmptyArray(modifiers.accept);
107+
if (types) {
108+
AND.push({
109+
OR: types.map(type => ({ type_startsWith: type }))
110+
});
111+
}
112+
}
113+
101114
if (state.filters) {
102115
AND.push(state.filters);
103116
}
@@ -130,7 +143,6 @@ export function useListFiles({ modifiers, folderId, state }: UseListFilesParams)
130143
...getScopeWhereParams(modifiers.scope),
131144
location: locationWhere,
132145
createdBy: modifiers.own ? identity!.id : undefined,
133-
type_in: nonEmptyArray(modifiers.accept),
134146
AND: AND.length > 0 ? AND : undefined
135147
}
136148
};

0 commit comments

Comments
 (0)