SULLEY\ryo-h пре 4 година
родитељ
комит
c152642650

+ 13 - 13
packages/app/src/components/SearchPage.jsx

@@ -185,20 +185,20 @@ class SearchPage extends React.Component {
     });
   }
 
-  getCheckboxType = (selectedPagesCount) => {
-    switch (selectedPagesCount) {
-      case 0:
-        return CheckboxType.NONE_CHECKED;
-      case this.state.searchedPages.length:
-        return CheckboxType.ALL_CHECKED;
-      default:
-        return CheckboxType.INDETERMINATE;
-    }
-  }
-
   updateCheckboxState = () => {
-    const currentCheckboxState = this.getCheckboxType(this.state.selectedPages.size);
-    this.setState({ checkboxState: currentCheckboxState });
+    function getCheckboxType(selectedPagesCount, searchedPagesCount) {
+      switch (selectedPagesCount) {
+        case 0:
+          return CheckboxType.NONE_CHECKED;
+        case searchedPagesCount:
+          return CheckboxType.ALL_CHECKED;
+        default:
+          return CheckboxType.INDETERMINATE;
+      }
+    }
+    this.setState({
+      checkboxState: getCheckboxType(this.state.selectedPages.size, this.state.searchedPages.length),
+    });
   }
 
   toggleCheckBox = (page) => {

+ 0 - 4
packages/app/src/components/SearchPage/SearchControl.tsx

@@ -5,10 +5,6 @@ import AppContainer from '../../client/services/AppContainer';
 import DeleteSelectedPageGroup from './DeleteSelectedPageGroup';
 import { CheckboxType } from '../../interfaces/search';
 
-import loggerFactory from '~/utils/logger';
-
-const logger = loggerFactory('growi:searchResultList');
-
 type Props = {
   searchingKeyword: string,
   checkboxState: CheckboxType,

+ 12 - 18
packages/app/src/components/SearchPage/SearchResultListItem.tsx

@@ -85,20 +85,22 @@ const SearchResultListItem: FC<Props> = (props:Props) => {
   const dPagePath = new DevidedPagePath(page.path, false, true);
   const pagePathElem = <PagePathLabel page={page} isFormerOnly />;
 
+  const onClickSearchedResultItem = () => {
+    if (onClickInvoked == null) { throw new Error('onClickInvoked is null') }
+    onClickInvoked(page._id);
+  };
+
+  const onClickCheckbox = () => {
+    if (onClickCheckboxInvoked == null) { throw new Error('onClickCheckboxInvoked is null') }
+    onClickCheckboxInvoked(page);
+  };
+
   return (
     <li key={page._id} className={`page-list-li search-page-item w-100 border-bottom pr-4 list-group-item-action ${isSelected ? 'active' : ''}`}>
       <a
         className="d-block pt-3"
         href={pageId}
-        onClick={() => {
-          try {
-            if (onClickInvoked == null) { throw new Error('onClickInvoked is null') }
-            onClickInvoked(page._id);
-          }
-          catch (error) {
-            logger.error(error);
-          }
-        }}
+        onClick={onClickSearchedResultItem}
       >
         <div className="d-flex">
           {/* checkbox */}
@@ -107,15 +109,7 @@ const SearchResultListItem: FC<Props> = (props:Props) => {
               className="form-check-input my-auto"
               type="checkbox"
               id="flexCheckDefault"
-              onClick={() => {
-                try {
-                  if (onClickCheckboxInvoked == null) { throw new Error('onClickCheckboxInvoked is null') }
-                  onClickCheckboxInvoked(page);
-                }
-                catch (error) {
-                  logger.error(error);
-                }
-              }}
+              onClick={onClickCheckbox}
             />
           </div>
           <div className="w-100">