Skip to content

Commit

Permalink
merge seasearch and es
Browse files Browse the repository at this point in the history
  • Loading branch information
JoinTyang committed Aug 24, 2024
1 parent a2c8528 commit c9e9737
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 1,225 deletions.
24 changes: 7 additions & 17 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, enableSeasearch, enableElasticsearch } from '../../utils/constants';
import { gettext, isPro } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import toaster from '../toast';
import RepoInfo from '../../models/repo-info';
Expand Down Expand Up @@ -242,23 +242,13 @@ class FileChooser extends React.Component {
};

sendRequest = (queryData, cancelToken) => {
if (isPro && enableSeasearch && !enableElasticsearch) {
seafileAPI.aiSearchFiles(queryData, cancelToken).then(res => {
this.setState({
searchResults: res.data.results.length > 0 ? this.formatResultItems(res.data.results.filter(item => item.is_dir)) : [],
isResultGot: true
});
this.source = null;
});
} else {
seafileAPI.searchFiles(queryData, cancelToken).then(res => {
this.setState({
searchResults: res.data.total ? this.formatResultItems(res.data.results) : [],
isResultGot: true
});
this.source = null;
seafileAPI.searchFiles(queryData, cancelToken).then(res => {
this.setState({
searchResults: res.data.total ? this.formatResultItems(res.data.results) : [],
isResultGot: true
});
}
this.source = null;
});
};

cancelRequest = () => {
Expand Down
Loading

0 comments on commit c9e9737

Please sign in to comment.