Skip to content

Commit

Permalink
fix search file when move file or dirent
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael18811380328 committed Aug 2, 2024
1 parent 51b8706 commit 647c4d0
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions frontend/src/components/file-chooser/file-chooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { Input } from 'reactstrap';
import { seafileAPI } from '../../utils/seafile-api';
import { gettext, isPro } from '../../utils/constants';
import { gettext, isPro, enableSeasearch, enableElasticsearch } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import toaster from '../toast';
import RepoInfo from '../../models/repo-info';
Expand Down Expand Up @@ -211,23 +211,23 @@ class FileChooser extends React.Component {
};

sendRequest = (queryData, cancelToken) => {
seafileAPI.searchFiles(queryData, cancelToken).then(res => {
if (!res.data.total) {
this.setState({
searchResults: [],
isResultGot: true
});
this.source = null;
return;
}

let items = this.formatResultItems(res.data.results);
this.setState({
searchResults: items,
isResultGot: true
if (isPro && enableSeasearch && !enableElasticsearch) {
seafileAPI.aiSearchFiles(queryData, cancelToken).then(res => {
this.handleSearchResult(res);
});
} else {
seafileAPI.searchFiles(queryData, cancelToken).then(res => {
this.handleSearchResult(res);
});
this.source = null;
}
};

handleSearchResult = (res) => {
this.setState({
searchResults: res.data.total ? this.formatResultItems(res.data.results) : [],
isResultGot: true
});
this.source = null;
};

cancelRequest = () => {
Expand Down

0 comments on commit 647c4d0

Please sign in to comment.