Просмотр исходного кода

Add hiding setting to swr argument

arvid-e 2 месяцев назад
Родитель
Сommit
cb59122b8a
1 измененных файлов с 12 добавлено и 3 удалено
  1. 12 3
      apps/app/src/client/components/SearchTypeahead.tsx

+ 12 - 3
apps/app/src/client/components/SearchTypeahead.tsx

@@ -25,6 +25,7 @@ import type { IFocusable } from '~/client/interfaces/focusable';
 import type { TypeaheadProps } from '~/client/interfaces/react-bootstrap-typeahead';
 import type { IPageWithSearchMeta } from '~/interfaces/search';
 import { useSWRxSearch } from '~/stores/search';
+import { useSWRxSecuritySettings } from '~/stores/security-settings';
 
 import styles from './SearchTypeahead.module.scss';
 
@@ -83,13 +84,21 @@ const SearchTypeahead: ForwardRefRenderFunction<IFocusable, Props> = (
   const [searchKeyword, setSearchKeyword] = useState('');
   const [isFocused, setFocused] = useState(false);
 
+  const { data: generalSetting } = useSWRxSecuritySettings();
+  const isHidingUserPages = generalSetting?.isHidingUserPages ?? false;
+
   const {
     data: searchResult,
     error: searchError,
     isLoading,
-  } = useSWRxSearch(disableIncrementalSearch ? null : searchKeyword, null, {
-    limit: 10,
-  });
+  } = useSWRxSearch(
+    disableIncrementalSearch ? null : searchKeyword,
+    null,
+    {
+      limit: 10,
+    },
+    isHidingUserPages,
+  );
 
   const typeaheadRef = useRef<TypeaheadRef>(null);