Skip to content

Commit

Permalink
fix(ui): adjust file client to match API change
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Nov 27, 2024
1 parent 57df04f commit c47dddb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions api/service/file_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func (svc *FileService) ListByPath(path string, userID string) ([]*File, error)
}

type FileQuery struct {
Text string `json:"text" validate:"required"`
Text *string `json:"text" validate:"required"`
Type *string `json:"type,omitempty" validate:"omitempty,oneof=file folder"`
CreateTimeAfter *int64 `json:"createTimeAfter,omitempty"`
CreateTimeBefore *int64 `json:"createTimeBefore,omitempty"`
Expand Down Expand Up @@ -669,12 +669,12 @@ func (svc *FileService) List(id string, opts FileListOptions, userID string) (*F
return nil, err
}
var data []model.File
if opts.Query != nil && opts.Query.Text != "" {
if opts.Query != nil && opts.Query.Text != nil {
count, err := svc.fileRepo.Count()
if err != nil {
return nil, err
}
data, err = svc.fileSearch.Query(opts.Query.Text, infra.QueryOptions{Limit: count})
data, err = svc.fileSearch.Query(*opts.Query.Text, infra.QueryOptions{Limit: count})
if err != nil {
return nil, err
}
Expand Down
6 changes: 1 addition & 5 deletions ui/src/client/api/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type GroupPermission = {
}

export type Query = {
text: string
text?: string
type?: FileType
createTimeAfter?: number
createTimeBefore?: number
Expand All @@ -81,7 +81,6 @@ export type Query = {
export type ListOptions = {
size?: number
page?: number
type?: FileType
sortBy?: SortBy
sortOrder?: SortOrder
query?: Query
Expand Down Expand Up @@ -289,9 +288,6 @@ export default class FileAPI {
if (options?.sortOrder) {
params.sort_order = options.sortOrder.toString()
}
if (options?.type) {
params.type = options.type
}
if (options?.query) {
params.query = encodeQuery(JSON.stringify(options.query))
}
Expand Down
8 changes: 6 additions & 2 deletions ui/src/components/file/file-browse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ const FileBrowse = ({ onChange }: FileBrowseProps) => {
const timeoutId = setTimeout(() => setIsSpinnerVisible(true), 250)
const result = await FileAPI.list(fileId, {
page: 1,
type: FileType.Folder,
query: {
type: FileType.Folder,
},
})
clearTimeout(timeoutId)
setTotalPages(result.totalPages)
Expand All @@ -67,7 +69,9 @@ const FileBrowse = ({ onChange }: FileBrowseProps) => {
setIsLoading(true)
const result = await FileAPI.list(fileId, {
page,
type: FileType.Folder,
query: {
type: FileType.Folder,
},
})
setTotalPages(result.totalPages)
setFolders(result.data)
Expand Down

0 comments on commit c47dddb

Please sign in to comment.