@selfcommunity/react-core 0.6.7-alpha.12 → 0.6.7-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { SCCategoryType } from '@selfcommunity/types';
2
+ import { CategoryParams } from '@selfcommunity/api-services';
2
3
  import { CacheStrategies } from '@selfcommunity/utils';
3
4
  /**
4
5
  :::info
@@ -14,6 +15,7 @@ import { CacheStrategies } from '@selfcommunity/utils';
14
15
  */
15
16
  declare const useSCFetchCategories: (props?: {
16
17
  cacheStrategy?: CacheStrategies;
18
+ endpointQueryParams?: CategoryParams;
17
19
  }) => {
18
20
  categories: SCCategoryType[];
19
21
  isLoading: boolean;
@@ -36,7 +36,7 @@ const hydrate = (ids) => {
36
36
  */
37
37
  const useSCFetchCategories = (props) => {
38
38
  // PROPS
39
- const { cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST } = props || {};
39
+ const { cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, endpointQueryParams = {} } = props || {};
40
40
  // CACHE
41
41
  const __categoriesCacheKey = (0, Cache_1.getCategoriesObjectCacheKey)();
42
42
  // STATE
@@ -46,7 +46,7 @@ const useSCFetchCategories = (props) => {
46
46
  * Fetch categories
47
47
  */
48
48
  const fetchCategories = (next = api_services_1.Endpoints.CategoryList.url()) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
49
- const data = yield api_services_1.CategoryService.getAllCategories({ active: true }, { url: next });
49
+ const data = yield api_services_1.CategoryService.getAllCategories(Object.assign({ active: true }, endpointQueryParams), { url: next });
50
50
  return data.next ? data.results.concat(yield fetchCategories(data.next)) : data.results;
51
51
  });
52
52
  /**
@@ -71,7 +71,7 @@ function useSCFetchUserBlockedBy({ user = null, blockedByUser = null, sync = tru
71
71
  */
72
72
  (0, react_1.useEffect)(() => {
73
73
  let interval;
74
- if (scUserContext.user && blockedBy !== null && sync) {
74
+ if (scUserContext.user && scUserContext.user.id !== (user === null || user === void 0 ? void 0 : user.id) && blockedBy !== null && sync) {
75
75
  interval = setInterval(() => {
76
76
  fetchUserBlockedBy(user, false);
77
77
  }, 5000);
@@ -1,4 +1,5 @@
1
1
  import { SCCategoryType } from '@selfcommunity/types';
2
+ import { CategoryParams } from '@selfcommunity/api-services';
2
3
  import { CacheStrategies } from '@selfcommunity/utils';
3
4
  /**
4
5
  :::info
@@ -14,6 +15,7 @@ import { CacheStrategies } from '@selfcommunity/utils';
14
15
  */
15
16
  declare const useSCFetchCategories: (props?: {
16
17
  cacheStrategy?: CacheStrategies;
18
+ endpointQueryParams?: CategoryParams;
17
19
  }) => {
18
20
  categories: SCCategoryType[];
19
21
  isLoading: boolean;
@@ -34,7 +34,7 @@ const hydrate = (ids) => {
34
34
  */
35
35
  const useSCFetchCategories = (props) => {
36
36
  // PROPS
37
- const { cacheStrategy = CacheStrategies.CACHE_FIRST } = props || {};
37
+ const { cacheStrategy = CacheStrategies.CACHE_FIRST, endpointQueryParams = {} } = props || {};
38
38
  // CACHE
39
39
  const __categoriesCacheKey = getCategoriesObjectCacheKey();
40
40
  // STATE
@@ -44,7 +44,7 @@ const useSCFetchCategories = (props) => {
44
44
  * Fetch categories
45
45
  */
46
46
  const fetchCategories = (next = Endpoints.CategoryList.url()) => __awaiter(void 0, void 0, void 0, function* () {
47
- const data = yield CategoryService.getAllCategories({ active: true }, { url: next });
47
+ const data = yield CategoryService.getAllCategories(Object.assign({ active: true }, endpointQueryParams), { url: next });
48
48
  return data.next ? data.results.concat(yield fetchCategories(data.next)) : data.results;
49
49
  });
50
50
  /**
@@ -69,7 +69,7 @@ export default function useSCFetchUserBlockedBy({ user = null, blockedByUser = n
69
69
  */
70
70
  useEffect(() => {
71
71
  let interval;
72
- if (scUserContext.user && blockedBy !== null && sync) {
72
+ if (scUserContext.user && scUserContext.user.id !== (user === null || user === void 0 ? void 0 : user.id) && blockedBy !== null && sync) {
73
73
  interval = setInterval(() => {
74
74
  fetchUserBlockedBy(user, false);
75
75
  }, 5000);