|
@@ -14,6 +14,7 @@ import SearchControl from './SearchPage/SearchControl';
|
|
|
import { CheckboxType, SORT_AXIS, SORT_ORDER } from '~/interfaces/search';
|
|
import { CheckboxType, SORT_AXIS, SORT_ORDER } from '~/interfaces/search';
|
|
|
import PageDeleteModal from './PageDeleteModal';
|
|
import PageDeleteModal from './PageDeleteModal';
|
|
|
import { useIsGuestUser } from '~/stores/context';
|
|
import { useIsGuestUser } from '~/stores/context';
|
|
|
|
|
+import { apiv3Get } from '~/client/util/apiv3-client';
|
|
|
|
|
|
|
|
export const specificPathNames = {
|
|
export const specificPathNames = {
|
|
|
user: '/user',
|
|
user: '/user',
|
|
@@ -34,6 +35,7 @@ class SearchPage extends React.Component {
|
|
|
focusedSearchResultData: null,
|
|
focusedSearchResultData: null,
|
|
|
selectedPagesIdList: new Set(),
|
|
selectedPagesIdList: new Set(),
|
|
|
searchResultCount: 0,
|
|
searchResultCount: 0,
|
|
|
|
|
+ shortBodiesMap: null,
|
|
|
activePage: 1,
|
|
activePage: 1,
|
|
|
pagingLimit: this.props.appContainer.config.pageLimitationL || 50,
|
|
pagingLimit: this.props.appContainer.config.pageLimitationL || 50,
|
|
|
excludeUserPages: true,
|
|
excludeUserPages: true,
|
|
@@ -140,6 +142,11 @@ class SearchPage extends React.Component {
|
|
|
this.setState({ pagingLimit: limit }, () => this.search({ keyword: this.state.searchedKeyword }));
|
|
this.setState({ pagingLimit: limit }, () => this.search({ keyword: this.state.searchedKeyword }));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ async fetchShortBodiesMap(pageIds) {
|
|
|
|
|
+ const res = await apiv3Get('/page-listing/short-bodies', { pageIds });
|
|
|
|
|
+ this.setState({ shortBodiesMap: res.data.shortBodiesMap });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// todo: refactoring
|
|
// todo: refactoring
|
|
|
// refs: https://redmine.weseek.co.jp/issues/82139
|
|
// refs: https://redmine.weseek.co.jp/issues/82139
|
|
|
async search(data) {
|
|
async search(data) {
|
|
@@ -171,6 +178,19 @@ class SearchPage extends React.Component {
|
|
|
sort,
|
|
sort,
|
|
|
order,
|
|
order,
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * non-await asynchronous short body fetch
|
|
|
|
|
+ */
|
|
|
|
|
+ const pageIds = res.data.map((page) => {
|
|
|
|
|
+ if (page.pageMeta?.elasticSearchResult != null && page.pageMeta?.elasticSearchResult?.snippet.length !== 0) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return page.pageData._id;
|
|
|
|
|
+ }).filter(id => id != null);
|
|
|
|
|
+ this.fetchShortBodiesMap(pageIds);
|
|
|
|
|
+
|
|
|
this.changeURL(keyword);
|
|
this.changeURL(keyword);
|
|
|
if (res.data.length > 0) {
|
|
if (res.data.length > 0) {
|
|
|
this.setState({
|
|
this.setState({
|
|
@@ -288,6 +308,7 @@ class SearchPage extends React.Component {
|
|
|
focusedSearchResultData={this.state.focusedSearchResultData}
|
|
focusedSearchResultData={this.state.focusedSearchResultData}
|
|
|
selectedPagesIdList={this.state.selectedPagesIdList || []}
|
|
selectedPagesIdList={this.state.selectedPagesIdList || []}
|
|
|
searchResultCount={this.state.searchResultCount}
|
|
searchResultCount={this.state.searchResultCount}
|
|
|
|
|
+ shortBodiesMap={this.state.shortBodiesMap}
|
|
|
activePage={this.state.activePage}
|
|
activePage={this.state.activePage}
|
|
|
pagingLimit={this.state.pagingLimit}
|
|
pagingLimit={this.state.pagingLimit}
|
|
|
onClickSearchResultItem={this.selectPage}
|
|
onClickSearchResultItem={this.selectPage}
|