|
@@ -1,4 +1,4 @@
|
|
|
-import React, { FC } from 'react';
|
|
|
|
|
|
|
+import React, { FC, memo } from 'react';
|
|
|
|
|
|
|
|
import Clamp from 'react-multiline-clamp';
|
|
import Clamp from 'react-multiline-clamp';
|
|
|
|
|
|
|
@@ -14,15 +14,16 @@ type Props = {
|
|
|
isSelected: boolean,
|
|
isSelected: boolean,
|
|
|
isChecked: boolean,
|
|
isChecked: boolean,
|
|
|
isEnableActions: boolean,
|
|
isEnableActions: boolean,
|
|
|
|
|
+ shortBody?: string
|
|
|
onClickCheckbox?: (pageId: string) => void,
|
|
onClickCheckbox?: (pageId: string) => void,
|
|
|
onClickSearchResultItem?: (pageId: string) => void,
|
|
onClickSearchResultItem?: (pageId: string) => void,
|
|
|
onClickDeleteButton?: (pageId: string) => void,
|
|
onClickDeleteButton?: (pageId: string) => void,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const SearchResultListItem: FC<Props> = (props:Props) => {
|
|
|
|
|
|
|
+const SearchResultListItem: FC<Props> = memo((props:Props) => {
|
|
|
const {
|
|
const {
|
|
|
// todo: refactoring variable name to clear what changed
|
|
// todo: refactoring variable name to clear what changed
|
|
|
- page: { pageData, pageMeta }, isSelected, onClickSearchResultItem, onClickCheckbox, isChecked, isEnableActions,
|
|
|
|
|
|
|
+ page: { pageData, pageMeta }, isSelected, onClickSearchResultItem, onClickCheckbox, isChecked, isEnableActions, shortBody,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
// Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral.
|
|
// Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral.
|
|
@@ -82,13 +83,15 @@ const SearchResultListItem: FC<Props> = (props:Props) => {
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="my-2">
|
|
<div className="my-2">
|
|
|
- {
|
|
|
|
|
- pageMeta.elasticSearchResult != null && (
|
|
|
|
|
- <Clamp lines={2}>
|
|
|
|
|
|
|
+ <Clamp lines={2}>
|
|
|
|
|
+ {
|
|
|
|
|
+ pageMeta.elasticSearchResult != null && pageMeta.elasticSearchResult?.snippet.length !== 0 ? (
|
|
|
<div className="mt-1" dangerouslySetInnerHTML={{ __html: pageMeta.elasticSearchResult.snippet }}></div>
|
|
<div className="mt-1" dangerouslySetInnerHTML={{ __html: pageMeta.elasticSearchResult.snippet }}></div>
|
|
|
- </Clamp>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <div className="mt-1">{ shortBody != null ? shortBody : 'Loading ...' }</div> // TODO: improve indicator
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ </Clamp>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -96,6 +99,6 @@ const SearchResultListItem: FC<Props> = (props:Props) => {
|
|
|
</a>
|
|
</a>
|
|
|
</li>
|
|
</li>
|
|
|
);
|
|
);
|
|
|
-};
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
export default SearchResultListItem;
|
|
export default SearchResultListItem;
|