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

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.
@@ -8,7 +8,7 @@ const utils_1 = require("@selfcommunity/utils");
8
8
  const Cache_1 = require("../constants/Cache");
9
9
  const init = { categories: [], isLoading: true };
10
10
  // HYDRATE the cache
11
- const hydrate = (ids) => {
11
+ const hydrate = (ids, endpointQueryParams) => {
12
12
  if (!ids) {
13
13
  return null;
14
14
  }
@@ -20,6 +20,9 @@ const hydrate = (ids) => {
20
20
  // REVALIDATE CACHE
21
21
  return null;
22
22
  }
23
+ if (endpointQueryParams === null || endpointQueryParams === void 0 ? void 0 : endpointQueryParams.can_create_content) {
24
+ return categories.filter((c) => !c.content_only_staff);
25
+ }
23
26
  return categories;
24
27
  };
25
28
  /**
@@ -40,7 +43,7 @@ const useSCFetchCategories = (props) => {
40
43
  // CACHE
41
44
  const __categoriesCacheKey = (0, Cache_1.getCategoriesObjectCacheKey)();
42
45
  // STATE
43
- const categories = cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? hydrate(utils_1.LRUCache.get(__categoriesCacheKey, null)) : null;
46
+ const categories = cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? hydrate(utils_1.LRUCache.get(__categoriesCacheKey, null), endpointQueryParams) : null;
44
47
  const [data, setData] = (0, react_1.useState)(categories !== null ? { categories, isLoading: false } : init);
45
48
  /**
46
49
  * Fetch categories
@@ -6,7 +6,7 @@ import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
6
6
  import { getCategoriesObjectCacheKey, getCategoryObjectCacheKey } from '../constants/Cache';
7
7
  const init = { categories: [], isLoading: true };
8
8
  // HYDRATE the cache
9
- const hydrate = (ids) => {
9
+ const hydrate = (ids, endpointQueryParams) => {
10
10
  if (!ids) {
11
11
  return null;
12
12
  }
@@ -18,6 +18,9 @@ const hydrate = (ids) => {
18
18
  // REVALIDATE CACHE
19
19
  return null;
20
20
  }
21
+ if (endpointQueryParams === null || endpointQueryParams === void 0 ? void 0 : endpointQueryParams.can_create_content) {
22
+ return categories.filter((c) => !c.content_only_staff);
23
+ }
21
24
  return categories;
22
25
  };
23
26
  /**
@@ -38,7 +41,7 @@ const useSCFetchCategories = (props) => {
38
41
  // CACHE
39
42
  const __categoriesCacheKey = getCategoriesObjectCacheKey();
40
43
  // STATE
41
- const categories = cacheStrategy !== CacheStrategies.NETWORK_ONLY ? hydrate(LRUCache.get(__categoriesCacheKey, null)) : null;
44
+ const categories = cacheStrategy !== CacheStrategies.NETWORK_ONLY ? hydrate(LRUCache.get(__categoriesCacheKey, null), endpointQueryParams) : null;
42
45
  const [data, setData] = useState(categories !== null ? { categories, isLoading: false } : init);
43
46
  /**
44
47
  * Fetch categories