@selfcommunity/react-core 0.4.9-alpha.9 → 0.4.9

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.
Files changed (72) hide show
  1. package/lib/cjs/components/provider/SCContextProvider/index.d.ts +2 -3
  2. package/lib/cjs/components/provider/SCContextProvider/index.js +2 -3
  3. package/lib/cjs/components/provider/SCPreferencesProvider/index.js +1 -1
  4. package/lib/cjs/constants/Cache.d.ts +1 -0
  5. package/lib/cjs/constants/Cache.js +2 -1
  6. package/lib/cjs/constants/Notification.d.ts +4 -0
  7. package/lib/cjs/constants/Notification.js +4 -0
  8. package/lib/cjs/constants/Routes.d.ts +1 -0
  9. package/lib/cjs/constants/Routes.js +3 -1
  10. package/lib/cjs/hooks/useSCFetchAddressingTagList.d.ts +1 -2
  11. package/lib/cjs/hooks/useSCFetchAddressingTagList.js +1 -2
  12. package/lib/cjs/hooks/useSCFetchBroadcastMessages.d.ts +1 -2
  13. package/lib/cjs/hooks/useSCFetchBroadcastMessages.js +1 -2
  14. package/lib/cjs/hooks/useSCFetchCategories.d.ts +1 -2
  15. package/lib/cjs/hooks/useSCFetchCategories.js +3 -11
  16. package/lib/cjs/hooks/useSCFetchCommentObject.d.ts +1 -1
  17. package/lib/cjs/hooks/useSCFetchCommentObject.js +1 -1
  18. package/lib/cjs/hooks/useSCFetchCommentObjects.d.ts +1 -7
  19. package/lib/cjs/hooks/useSCFetchCommentObjects.js +1 -8
  20. package/lib/cjs/hooks/useSCFetchContributors.d.ts +1 -5
  21. package/lib/cjs/hooks/useSCFetchContributors.js +1 -5
  22. package/lib/cjs/hooks/useSCFetchCustomAdv.d.ts +3 -2
  23. package/lib/cjs/hooks/useSCFetchCustomAdv.js +3 -2
  24. package/lib/cjs/hooks/useSCFetchFeed.d.ts +1 -5
  25. package/lib/cjs/hooks/useSCFetchFeed.js +1 -5
  26. package/lib/cjs/hooks/useSCFetchGroup.d.ts +1 -2
  27. package/lib/cjs/hooks/useSCFetchGroup.js +8 -7
  28. package/lib/cjs/hooks/useSCFetchGroups.js +2 -2
  29. package/lib/cjs/hooks/useSCFetchUserBlockedBy.d.ts +4 -2
  30. package/lib/cjs/hooks/useSCFetchUserBlockedBy.js +4 -2
  31. package/lib/cjs/hooks/useSCFetchUserProviders.d.ts +2 -2
  32. package/lib/cjs/hooks/useSCFetchUserProviders.js +2 -2
  33. package/lib/cjs/hooks/useSCFetchVote.d.ts +6 -0
  34. package/lib/cjs/hooks/useSCFetchVote.js +6 -0
  35. package/lib/cjs/hooks/useSCSubscribedGroupsManager.js +10 -5
  36. package/lib/esm/components/provider/SCContextProvider/index.d.ts +2 -3
  37. package/lib/esm/components/provider/SCContextProvider/index.js +2 -3
  38. package/lib/esm/components/provider/SCPreferencesProvider/index.js +1 -1
  39. package/lib/esm/constants/Cache.d.ts +1 -0
  40. package/lib/esm/constants/Cache.js +1 -0
  41. package/lib/esm/constants/Notification.d.ts +4 -0
  42. package/lib/esm/constants/Notification.js +4 -0
  43. package/lib/esm/constants/Routes.d.ts +1 -0
  44. package/lib/esm/constants/Routes.js +2 -0
  45. package/lib/esm/hooks/useSCFetchAddressingTagList.d.ts +1 -2
  46. package/lib/esm/hooks/useSCFetchAddressingTagList.js +1 -2
  47. package/lib/esm/hooks/useSCFetchBroadcastMessages.d.ts +1 -2
  48. package/lib/esm/hooks/useSCFetchBroadcastMessages.js +1 -2
  49. package/lib/esm/hooks/useSCFetchCategories.d.ts +1 -2
  50. package/lib/esm/hooks/useSCFetchCategories.js +4 -12
  51. package/lib/esm/hooks/useSCFetchCommentObject.d.ts +1 -1
  52. package/lib/esm/hooks/useSCFetchCommentObject.js +1 -1
  53. package/lib/esm/hooks/useSCFetchCommentObjects.d.ts +1 -7
  54. package/lib/esm/hooks/useSCFetchCommentObjects.js +1 -8
  55. package/lib/esm/hooks/useSCFetchContributors.d.ts +1 -5
  56. package/lib/esm/hooks/useSCFetchContributors.js +1 -5
  57. package/lib/esm/hooks/useSCFetchCustomAdv.d.ts +3 -2
  58. package/lib/esm/hooks/useSCFetchCustomAdv.js +3 -2
  59. package/lib/esm/hooks/useSCFetchFeed.d.ts +1 -5
  60. package/lib/esm/hooks/useSCFetchFeed.js +1 -5
  61. package/lib/esm/hooks/useSCFetchGroup.d.ts +1 -2
  62. package/lib/esm/hooks/useSCFetchGroup.js +8 -7
  63. package/lib/esm/hooks/useSCFetchGroups.js +2 -2
  64. package/lib/esm/hooks/useSCFetchUserBlockedBy.d.ts +4 -2
  65. package/lib/esm/hooks/useSCFetchUserBlockedBy.js +4 -2
  66. package/lib/esm/hooks/useSCFetchUserProviders.d.ts +2 -2
  67. package/lib/esm/hooks/useSCFetchUserProviders.js +2 -2
  68. package/lib/esm/hooks/useSCFetchVote.d.ts +6 -0
  69. package/lib/esm/hooks/useSCFetchVote.js +6 -0
  70. package/lib/esm/hooks/useSCSubscribedGroupsManager.js +11 -6
  71. package/lib/umd/react-core.js +1 -1
  72. package/package.json +6 -6
@@ -44,6 +44,10 @@ export declare const SCNotificationMapping: {
44
44
  83: SCNotificationTypologyType;
45
45
  96: SCNotificationTypologyType;
46
46
  99: SCNotificationTypologyType;
47
+ 31: SCNotificationTypologyType;
48
+ 32: SCNotificationTypologyType;
49
+ 33: SCNotificationTypologyType;
50
+ 34: SCNotificationTypologyType;
47
51
  };
48
52
  /**
49
53
  * Silent Snippet Notifications
@@ -44,6 +44,10 @@ export const SCNotificationMapping = {
44
44
  83: SCNotificationTypologyType.UNBLOCKED_USER,
45
45
  96: SCNotificationTypologyType.INCUBATOR_APPROVED,
46
46
  99: SCNotificationTypologyType.CUSTOM_NOTIFICATION,
47
+ 31: SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP,
48
+ 32: SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP,
49
+ 33: SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP,
50
+ 34: SCNotificationTypologyType.USER_ADDED_TO_GROUP
47
51
  };
48
52
  /**
49
53
  * Silent Snippet Notifications
@@ -35,6 +35,7 @@ export declare const GROUP_ROUTE_NAME = "group";
35
35
  export declare const GROUP_MEMBERS_ROUTE_NAME = "group_members";
36
36
  export declare const GROUP_MESSAGES_ROUTE_NAME = "group_messages";
37
37
  export declare const GROUPS_ROUTE_NAME = "groups";
38
+ export declare const GROUPS_SUBSCRIBED_ROUTE_NAME = "groups_subscribed";
38
39
  /**
39
40
  * Default Routes
40
41
  * @type {{[p: string]: string, '[POST_ROUTE_NAME]': string, '[INCUBATOR_ROUTE_NAME]': string, '[LOYALTY_ROUTE_NAME]': string, '[USER_NOTIFICATION_ROUTE_NAME]': string, '[USER_PRIVATE_MESSAGES_ROUTE_NAME]': string, '[COMMENT_ROUTE_NAME]': string, '[DISCUSSION_ROUTE_NAME]': string, '[CATEGORIES_ROUTE_NAME]': string, '[USER_PROFILE_ROUTE_NAME]': string, '[CATEGORY_ROUTE_NAME]': string, '[USER_PROFILE_SETTINGS_ROUTE_NAME]': string, '[STATUS_ROUTE_NAME]': string}}
@@ -35,6 +35,7 @@ export const GROUP_ROUTE_NAME = 'group';
35
35
  export const GROUP_MEMBERS_ROUTE_NAME = 'group_members';
36
36
  export const GROUP_MESSAGES_ROUTE_NAME = 'group_messages';
37
37
  export const GROUPS_ROUTE_NAME = 'groups';
38
+ export const GROUPS_SUBSCRIBED_ROUTE_NAME = 'groups_subscribed';
38
39
  /**
39
40
  * Default Routes
40
41
  * @type {{[p: string]: string, '[POST_ROUTE_NAME]': string, '[INCUBATOR_ROUTE_NAME]': string, '[LOYALTY_ROUTE_NAME]': string, '[USER_NOTIFICATION_ROUTE_NAME]': string, '[USER_PRIVATE_MESSAGES_ROUTE_NAME]': string, '[COMMENT_ROUTE_NAME]': string, '[DISCUSSION_ROUTE_NAME]': string, '[CATEGORIES_ROUTE_NAME]': string, '[USER_PROFILE_ROUTE_NAME]': string, '[CATEGORY_ROUTE_NAME]': string, '[USER_PROFILE_SETTINGS_ROUTE_NAME]': string, '[STATUS_ROUTE_NAME]': string}}
@@ -72,4 +73,5 @@ export const defaultRoutes = {
72
73
  [GROUP_MEMBERS_ROUTE_NAME]: '/group/:id/:slug/members/',
73
74
  [GROUP_MESSAGES_ROUTE_NAME]: '/group/:id/:slug/messages/',
74
75
  [GROUPS_ROUTE_NAME]: '/groups/',
76
+ [GROUPS_SUBSCRIBED_ROUTE_NAME]: '/groups/subscribed/',
75
77
  };
@@ -3,8 +3,7 @@ import { SCTagType } from '@selfcommunity/types';
3
3
  :::info
4
4
  This custom hook is used to fetch the addressing tag list for the session user
5
5
  :::
6
- * @param object
7
- * @param object.fetch
6
+ * @param fetch
8
7
  */
9
8
  export default function useSCFetchAddressingTagList({ fetch }: {
10
9
  fetch?: boolean;
@@ -7,8 +7,7 @@ import { useSCUser } from '../components/provider/SCUserProvider';
7
7
  :::info
8
8
  This custom hook is used to fetch the addressing tag list for the session user
9
9
  :::
10
- * @param object
11
- * @param object.fetch
10
+ * @param fetch
12
11
  */
13
12
  export default function useSCFetchAddressingTagList({ fetch = false }) {
14
13
  const [scAddressingTags, setSCAddressingTags] = useState([]);
@@ -4,8 +4,6 @@ import { CacheStrategies } from '@selfcommunity/utils';
4
4
  /**
5
5
  :::info
6
6
  This custom hook is used to fetch broadcast messages.
7
- @param object
8
- @param object.cacheStrategy
9
7
 
10
8
  :::tip Context can be consumed in this way:
11
9
 
@@ -13,6 +11,7 @@ import { CacheStrategies } from '@selfcommunity/utils';
13
11
  const {messages, isLoading} = useSCFetchBroadcastMessages();
14
12
  ```
15
13
  :::
14
+ * @param props
16
15
  */
17
16
  declare const useSCFetchBroadcastMessages: (props?: {
18
17
  cacheStrategy?: CacheStrategies;
@@ -19,8 +19,6 @@ const initialData = { results: [], next: broadcastMessagesRefreshUrl, previous:
19
19
  /**
20
20
  :::info
21
21
  This custom hook is used to fetch broadcast messages.
22
- @param object
23
- @param object.cacheStrategy
24
22
 
25
23
  :::tip Context can be consumed in this way:
26
24
 
@@ -28,6 +26,7 @@ const initialData = { results: [], next: broadcastMessagesRefreshUrl, previous:
28
26
  const {messages, isLoading} = useSCFetchBroadcastMessages();
29
27
  ```
30
28
  :::
29
+ * @param props
31
30
  */
32
31
  const useSCFetchBroadcastMessages = (props) => {
33
32
  // PROPS
@@ -3,8 +3,6 @@ import { CacheStrategies } from '@selfcommunity/utils';
3
3
  /**
4
4
  :::info
5
5
  This custom hook is used to fetch categories.
6
- @param object
7
- @param object.cacheStrategy
8
6
 
9
7
  :::tip Context can be consumed in this way:
10
8
 
@@ -12,6 +10,7 @@ import { CacheStrategies } from '@selfcommunity/utils';
12
10
  const {categories, isLoading} = useSCFetchCategories();
13
11
  ```
14
12
  :::
13
+ * @param props
15
14
  */
16
15
  declare const useSCFetchCategories: (props?: {
17
16
  cacheStrategy?: CacheStrategies;
@@ -1,7 +1,7 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { SCOPE_SC_CORE } from '../constants/Errors';
4
- import { Endpoints, http } from '@selfcommunity/api-services';
4
+ import { CategoryService, Endpoints } from '@selfcommunity/api-services';
5
5
  import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
6
6
  import { getCategoriesObjectCacheKey, getCategoryObjectCacheKey } from '../constants/Cache';
7
7
  const init = { categories: [], isLoading: true };
@@ -23,8 +23,6 @@ const hydrate = (ids) => {
23
23
  /**
24
24
  :::info
25
25
  This custom hook is used to fetch categories.
26
- @param object
27
- @param object.cacheStrategy
28
26
 
29
27
  :::tip Context can be consumed in this way:
30
28
 
@@ -32,6 +30,7 @@ const hydrate = (ids) => {
32
30
  const {categories, isLoading} = useSCFetchCategories();
33
31
  ```
34
32
  :::
33
+ * @param props
35
34
  */
36
35
  const useSCFetchCategories = (props) => {
37
36
  // PROPS
@@ -45,15 +44,8 @@ const useSCFetchCategories = (props) => {
45
44
  * Fetch categories
46
45
  */
47
46
  const fetchCategories = (next = Endpoints.CategoryList.url()) => __awaiter(void 0, void 0, void 0, function* () {
48
- const response = yield http.request({
49
- url: next,
50
- method: Endpoints.CategoryList.method,
51
- });
52
- const data = response.data;
53
- if (data.next) {
54
- return data.results.concat(yield fetchCategories(data.next));
55
- }
56
- return data.results;
47
+ const data = yield CategoryService.getAllCategories({ active: true }, { url: next });
48
+ return data.next ? data.results.concat(yield fetchCategories(data.next)) : data.results;
57
49
  });
58
50
  /**
59
51
  * Get categories
@@ -8,7 +8,7 @@ import { CacheStrategies } from '@selfcommunity/utils';
8
8
  * @param object
9
9
  * @param object.id
10
10
  * @param object.commentObject
11
- * @param cacheStrategy
11
+ * @param object.cacheStrategy
12
12
  */
13
13
  export default function useSCFetchCommentObject({ id, commentObject, cacheStrategy, }: {
14
14
  id?: number;
@@ -11,7 +11,7 @@ import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
11
11
  * @param object
12
12
  * @param object.id
13
13
  * @param object.commentObject
14
- * @param cacheStrategy
14
+ * @param object.cacheStrategy
15
15
  */
16
16
  export default function useSCFetchCommentObject({ id = null, commentObject = null, cacheStrategy = CacheStrategies.CACHE_FIRST, }) {
17
17
  const __commentObjectId = commentObject ? commentObject.id : id;
@@ -34,13 +34,7 @@ export declare const commentsObjectActionTypes: {
34
34
  :::info
35
35
  This custom hooks is used to fetch paginated comments.
36
36
  :::
37
- * @param id
38
- * @param feedObject
39
- * @param feedObjectType
40
- * @param offset
41
- * @param pageSize
42
- * @param orderBy
43
- * @param parent
37
+ * @param props
44
38
  */
45
39
  export default function useSCFetchCommentObjects(props: {
46
40
  id?: number;
@@ -94,20 +94,13 @@ function stateInitializer(data) {
94
94
  :::info
95
95
  This custom hooks is used to fetch paginated comments.
96
96
  :::
97
- * @param id
98
- * @param feedObject
99
- * @param feedObjectType
100
- * @param offset
101
- * @param pageSize
102
- * @param orderBy
103
- * @param parent
97
+ * @param props
104
98
  */
105
99
  export default function useSCFetchCommentObjects(props) {
106
100
  // PROPS
107
101
  const { id, feedObject, feedObjectType, offset = 0, pageSize = 5, orderBy = SCCommentsOrderBy.ADDED_AT_DESC, parent, onChangePage, cacheStrategy = CacheStrategies.NETWORK_ONLY, } = props;
108
102
  // FeedObject
109
103
  const { obj, setObj } = useSCFetchFeedObject({ id, feedObject, feedObjectType, cacheStrategy });
110
- const objId = obj ? obj.id : null;
111
104
  /**
112
105
  * Get next url
113
106
  */
@@ -33,11 +33,7 @@ export declare const contributorsObjectActionTypes: {
33
33
  :::info
34
34
  This custom hooks is used to fetch paginated contributors.
35
35
  :::
36
- * @param id
37
- * @param feedObject
38
- * @param feedObjectType
39
- * @param offset
40
- * @param pageSize
36
+ * @param props
41
37
  */
42
38
  export default function useSCFetchContributors(props: {
43
39
  id?: number;
@@ -72,11 +72,7 @@ function stateInitializer(data) {
72
72
  :::info
73
73
  This custom hooks is used to fetch paginated contributors.
74
74
  :::
75
- * @param id
76
- * @param feedObject
77
- * @param feedObjectType
78
- * @param offset
79
- * @param pageSize
75
+ * @param props
80
76
  */
81
77
  export default function useSCFetchContributors(props) {
82
78
  // PROPS
@@ -6,9 +6,10 @@ import { SCCustomAdvPosition, SCCustomAdvType } from '@selfcommunity/types';
6
6
  This custom hook is used to fetch a custom adv object.
7
7
  :::
8
8
  * @param object
9
+ * @param object.id
9
10
  * @param object.position
10
- * @param object.categoryId
11
- * @param cacheStrategy
11
+ * @param object.categoriesId
12
+ * @param object.cacheStrategy
12
13
  */
13
14
  export default function useSCFetchCustomAdv({ id, position, categoriesId, cacheStrategy, }: {
14
15
  id?: number;
@@ -9,9 +9,10 @@ import { getAdvObjectCacheKey } from '../constants/Cache';
9
9
  This custom hook is used to fetch a custom adv object.
10
10
  :::
11
11
  * @param object
12
+ * @param object.id
12
13
  * @param object.position
13
- * @param object.categoryId
14
- * @param cacheStrategy
14
+ * @param object.categoriesId
15
+ * @param object.cacheStrategy
15
16
  */
16
17
  export default function useSCFetchCustomAdv({ id = null, position = null, categoriesId = null, cacheStrategy = CacheStrategies.CACHE_FIRST, }) {
17
18
  const [scCustomAdv, setSCCustomAdv] = useState(id !== null && cacheStrategy === CacheStrategies.CACHE_FIRST && LRUCache.get(getAdvObjectCacheKey(id))
@@ -38,11 +38,7 @@ export declare const feedDataActionTypes: {
38
38
  :::info
39
39
  This custom hooks is used to fetch paginated Data.
40
40
  :::
41
- * @param endpoint
42
- * @param offset
43
- * @param pageSize
44
- * @param onChangePage
45
- * @param cacheStrategy
41
+ * @param props
46
42
  */
47
43
  export default function useSCFetchFeed(props: {
48
44
  id: string;
@@ -86,11 +86,7 @@ function stateInitializer(data) {
86
86
  :::info
87
87
  This custom hooks is used to fetch paginated Data.
88
88
  :::
89
- * @param endpoint
90
- * @param offset
91
- * @param pageSize
92
- * @param onChangePage
93
- * @param cacheStrategy
89
+ * @param props
94
90
  */
95
91
  export default function useSCFetchFeed(props) {
96
92
  // PROPS
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SCGroupType } from '@selfcommunity/types';
3
2
  import { CacheStrategies } from '@selfcommunity/utils';
4
3
  /**
@@ -16,6 +15,6 @@ export default function useSCFetchGroup({ id, group, cacheStrategy, }: {
16
15
  cacheStrategy?: CacheStrategies;
17
16
  }): {
18
17
  scGroup: SCGroupType;
19
- setSCGroup: import("react").Dispatch<import("react").SetStateAction<SCGroupType>>;
18
+ setSCGroup: (group: SCGroupType) => void;
20
19
  error: string;
21
20
  };
@@ -22,8 +22,13 @@ export default function useSCFetchGroup({ id = null, group = null, cacheStrategy
22
22
  // CACHE
23
23
  const __groupCacheKey = getGroupObjectCacheKey(__groupId);
24
24
  const __group = authUserId ? group : objectWithoutProperties(group, ['subscription_status']);
25
- const [scGroup, setSCGroup] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__groupCacheKey, __group) : null);
25
+ const [scGroup, setScGroup] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__groupCacheKey, __group) : null);
26
26
  const [error, setError] = useState(null);
27
+ const setSCGroup = (group) => {
28
+ const _c = authUserId ? group : objectWithoutProperties(group, ['subscription_status']);
29
+ setScGroup(_c);
30
+ LRUCache.set(__groupCacheKey, _c);
31
+ };
27
32
  /**
28
33
  * Memoized fetchTag
29
34
  */
@@ -47,9 +52,7 @@ export default function useSCFetchGroup({ id = null, group = null, cacheStrategy
47
52
  if (__groupId && (!scGroup || (scGroup && __groupId !== scGroup.id))) {
48
53
  fetchGroup()
49
54
  .then((obj) => {
50
- const _c = authUserId ? obj : objectWithoutProperties(obj, ['subscription_status']);
51
- setSCGroup(_c);
52
- LRUCache.set(__groupCacheKey, _c);
55
+ setSCGroup(obj);
53
56
  })
54
57
  .catch((err) => {
55
58
  LRUCache.delete(__groupCacheKey);
@@ -61,9 +64,7 @@ export default function useSCFetchGroup({ id = null, group = null, cacheStrategy
61
64
  }, [__groupId, authUserId]);
62
65
  useDeepCompareEffectNoCheck(() => {
63
66
  if (group) {
64
- const _c = authUserId ? group : objectWithoutProperties(group, ['subscription_status']);
65
- setSCGroup(_c);
66
- LRUCache.set(__groupCacheKey, _c);
67
+ setSCGroup(group);
67
68
  }
68
69
  }, [group, authUserId]);
69
70
  return { scGroup, setSCGroup, error };
@@ -44,10 +44,10 @@ const useSCFetchGroups = (props) => {
44
44
  /**
45
45
  * Fetch groups
46
46
  */
47
- const fetchGroups = (next = Endpoints.SearchGroups.url()) => __awaiter(void 0, void 0, void 0, function* () {
47
+ const fetchGroups = (next = Endpoints.GetUserGroups.url()) => __awaiter(void 0, void 0, void 0, function* () {
48
48
  const response = yield http.request({
49
49
  url: next,
50
- method: Endpoints.SearchGroups.method,
50
+ method: Endpoints.GetUserGroups.method,
51
51
  });
52
52
  const data = response.data;
53
53
  if (data.next) {
@@ -3,8 +3,10 @@ import { SCUserType } from '@selfcommunity/types';
3
3
  :::info
4
4
  This custom hook is used to fetch if a user is blocked by another user.
5
5
  :::
6
- * @param user
7
- * @param blockedByUser
6
+ * @param object
7
+ * @param object.user
8
+ * @param object.blockedByUser
9
+ * @param object.sync
8
10
  */
9
11
  export default function useSCFetchUserBlockedBy({ user, blockedByUser, sync, }: {
10
12
  user: SCUserType;
@@ -7,8 +7,10 @@ import { useSCUser } from '../components/provider/SCUserProvider';
7
7
  :::info
8
8
  This custom hook is used to fetch if a user is blocked by another user.
9
9
  :::
10
- * @param user
11
- * @param blockedByUser
10
+ * @param object
11
+ * @param object.user
12
+ * @param object.blockedByUser
13
+ * @param object.sync
12
14
  */
13
15
  export default function useSCFetchUserBlockedBy({ user = null, blockedByUser = null, sync = true, }) {
14
16
  const [blockedBy, setBlockedBy] = useState(null);
@@ -2,11 +2,11 @@
2
2
  import { SCUserProviderAssociationType } from '@selfcommunity/types';
3
3
  /**
4
4
  :::info
5
- This custom hook is used to fetch the listo of user providers.
5
+ This custom hook is used to fetch the list of user providers.
6
6
  :::
7
7
  * @param object
8
8
  * @param object.id
9
- * @param object.user
9
+ * @param object.providers
10
10
  */
11
11
  export default function useSCFetchUserProviders({ id, providers }: {
12
12
  id: number | string;
@@ -4,11 +4,11 @@ import { UserService } from '@selfcommunity/api-services';
4
4
  import { Logger } from '@selfcommunity/utils';
5
5
  /**
6
6
  :::info
7
- This custom hook is used to fetch the listo of user providers.
7
+ This custom hook is used to fetch the list of user providers.
8
8
  :::
9
9
  * @param object
10
10
  * @param object.id
11
- * @param object.user
11
+ * @param object.providers
12
12
  */
13
13
  export default function useSCFetchUserProviders({ id, providers = null }) {
14
14
  const [scUserProviders, setSCUserProviders] = useState(providers || []);
@@ -31,6 +31,12 @@ interface FetchVoteProps {
31
31
  :::info
32
32
  This custom hook is used to fetch a contribution vote.
33
33
  :::
34
+ * @param object
35
+ * @param object.id
36
+ * @param object.contribution
37
+ * @param object.contributionType
38
+ * @param object.onVote
39
+ * @param object.cacheStrategy
34
40
  */
35
41
  export default function useSCFetchVote({ id, contribution, contributionType, onVote, cacheStrategy, }: FetchVoteProps): {
36
42
  isLoading: boolean;
@@ -11,6 +11,12 @@ import { useSCVote } from '../components/provider/SCVoteProvider';
11
11
  :::info
12
12
  This custom hook is used to fetch a contribution vote.
13
13
  :::
14
+ * @param object
15
+ * @param object.id
16
+ * @param object.contribution
17
+ * @param object.contributionType
18
+ * @param object.onVote
19
+ * @param object.cacheStrategy
14
20
  */
15
21
  export default function useSCFetchVote({ id, contribution = null, contributionType, onVote = null, cacheStrategy = CacheStrategies.CACHE_FIRST, }) {
16
22
  // MEMO
@@ -1,9 +1,10 @@
1
1
  import { useEffect, useMemo } from 'react';
2
2
  import { Endpoints, http } from '@selfcommunity/api-services';
3
- import { SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
3
+ import { SCFeatureName, SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
4
4
  import useSCCachingManager from './useSCCachingManager';
5
5
  import { SCOPE_SC_CORE } from '../constants/Errors';
6
6
  import { Logger } from '@selfcommunity/utils';
7
+ import { useSCPreferences } from '../components/provider/SCPreferencesProvider';
7
8
  /**
8
9
  :::info
9
10
  This custom hook is used to manage the groups followed.
@@ -20,7 +21,9 @@ import { Logger } from '@selfcommunity/utils';
20
21
  */
21
22
  export default function useSCSubscribedGroupsManager(user) {
22
23
  const { cache, updateCache, emptyCache, data, setData, loading, setLoading, setUnLoading, isLoading } = useSCCachingManager();
24
+ const scPreferencesContext = useSCPreferences();
23
25
  const authUserId = user ? user.id : null;
26
+ const groupsDisabled = scPreferencesContext.features && !scPreferencesContext.features.includes(SCFeatureName.GROUPING);
24
27
  /**
25
28
  * Memoized refresh all groups
26
29
  * It makes a single request to the server and retrieves
@@ -40,9 +43,9 @@ export default function useSCSubscribedGroupsManager(user) {
40
43
  if (res.status >= 300) {
41
44
  return Promise.reject(res);
42
45
  }
43
- const groupsIds = res.data.map((g) => g.id);
46
+ const groupsIds = res.data.results.map((g) => g.id);
44
47
  updateCache(groupsIds);
45
- setData(groupsIds);
48
+ setData(res.data.results.map((g) => ({ [g.id]: g.subscription_status })));
46
49
  return Promise.resolve(res.data);
47
50
  })
48
51
  .catch((e) => {
@@ -85,7 +88,9 @@ export default function useSCSubscribedGroupsManager(user) {
85
88
  return Promise.reject(res);
86
89
  }
87
90
  updateCache([group.id]);
88
- setData((prev) => getDataUpdated(prev, group.id, group.privacy === SCGroupPrivacyType.PRIVATE ? SCGroupSubscriptionStatusType.REQUESTED : SCGroupSubscriptionStatusType.SUBSCRIBED));
91
+ setData((prev) => getDataUpdated(prev, group.id, group.privacy === SCGroupPrivacyType.PRIVATE && group.subscription_status !== SCGroupSubscriptionStatusType.INVITED
92
+ ? SCGroupSubscriptionStatusType.REQUESTED
93
+ : SCGroupSubscriptionStatusType.SUBSCRIBED));
89
94
  setUnLoading(group.id);
90
95
  return Promise.resolve(res.data);
91
96
  });
@@ -198,7 +203,7 @@ export default function useSCSubscribedGroupsManager(user) {
198
203
  }
199
204
  }
200
205
  return null;
201
- }, [data, loading, cache, authUserId]);
206
+ }, [loading, cache, authUserId]);
202
207
  /**
203
208
  * Empty cache on logout
204
209
  */
@@ -207,7 +212,7 @@ export default function useSCSubscribedGroupsManager(user) {
207
212
  emptyCache();
208
213
  }
209
214
  }, [authUserId]);
210
- if (!user) {
215
+ if (groupsDisabled || !user) {
211
216
  return { groups: data, loading, isLoading };
212
217
  }
213
218
  return { groups: data, loading, isLoading, subscribe, unsubscribe, subscriptionStatus, refresh, emptyCache };