@selfcommunity/react-ui 0.7.9-alpha.6 → 0.7.9-alpha.60

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 (160) hide show
  1. package/lib/cjs/components/BottomNavigation/BottomNavigation.js +2 -2
  2. package/lib/cjs/components/CategoryHeader/Skeleton.js +3 -2
  3. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  4. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  5. package/lib/cjs/components/Composer/Attributes/Attributes.js +3 -3
  6. package/lib/cjs/components/Composer/Composer.js +3 -3
  7. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
  8. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
  9. package/lib/cjs/components/FeedObject/Contributors/Contributors.js +1 -1
  10. package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
  11. package/lib/cjs/components/FeedObject/FeedObject.js +23 -6
  12. package/lib/cjs/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
  13. package/lib/cjs/components/Group/Group.d.ts +8 -0
  14. package/lib/cjs/components/Group/Group.js +40 -5
  15. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
  16. package/lib/cjs/components/GroupForm/GroupForm.js +33 -10
  17. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
  18. package/lib/cjs/components/GroupHeader/GroupHeader.js +53 -11
  19. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +40 -7
  20. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +33 -11
  21. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +74 -0
  22. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +221 -0
  23. package/lib/cjs/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
  24. package/lib/cjs/components/GroupInvitedWidget/Skeleton.js +38 -0
  25. package/lib/cjs/components/GroupInvitedWidget/constants.d.ts +1 -0
  26. package/lib/cjs/components/GroupInvitedWidget/constants.js +4 -0
  27. package/lib/cjs/components/GroupInvitedWidget/index.d.ts +4 -0
  28. package/lib/cjs/components/GroupInvitedWidget/index.js +8 -0
  29. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  30. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +8 -3
  31. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +25 -4
  32. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
  33. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
  34. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  35. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +145 -0
  36. package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
  37. package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
  38. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  39. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
  40. package/lib/cjs/components/Groups/Groups.d.ts +19 -16
  41. package/lib/cjs/components/Groups/Groups.js +85 -86
  42. package/lib/cjs/components/Groups/Skeleton.d.ts +4 -0
  43. package/lib/cjs/components/Groups/Skeleton.js +2 -2
  44. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  45. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +1 -1
  46. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
  47. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -4
  48. package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
  49. package/lib/cjs/components/Notification/Group/Group.js +78 -0
  50. package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
  51. package/lib/cjs/components/Notification/Group/index.js +5 -0
  52. package/lib/cjs/components/Notification/Notification.js +31 -1
  53. package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  54. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  55. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +12 -7
  56. package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  57. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  58. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
  59. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  60. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +45 -20
  61. package/lib/cjs/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +6 -0
  62. package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  63. package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
  64. package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
  65. package/lib/cjs/components/User/User.d.ts +6 -1
  66. package/lib/cjs/components/User/User.js +5 -4
  67. package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
  68. package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.js +46 -0
  69. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
  70. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +183 -0
  71. package/lib/cjs/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
  72. package/lib/cjs/components/UserSubscribedGroupsWidget/constants.js +4 -0
  73. package/lib/cjs/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
  74. package/lib/cjs/components/UserSubscribedGroupsWidget/index.js +8 -0
  75. package/lib/cjs/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
  76. package/lib/cjs/constants/PubSub.d.ts +28 -0
  77. package/lib/cjs/constants/PubSub.js +22 -0
  78. package/lib/cjs/index.d.ts +6 -2
  79. package/lib/cjs/index.js +15 -4
  80. package/lib/esm/components/BottomNavigation/BottomNavigation.js +2 -2
  81. package/lib/esm/components/CategoryHeader/Skeleton.js +3 -2
  82. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  83. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  84. package/lib/esm/components/Composer/Attributes/Attributes.js +3 -3
  85. package/lib/esm/components/Composer/Composer.js +3 -3
  86. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
  87. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
  88. package/lib/esm/components/FeedObject/Contributors/Contributors.js +1 -1
  89. package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
  90. package/lib/esm/components/FeedObject/FeedObject.js +24 -7
  91. package/lib/esm/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
  92. package/lib/esm/components/Group/Group.d.ts +8 -0
  93. package/lib/esm/components/Group/Group.js +44 -9
  94. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
  95. package/lib/esm/components/GroupForm/GroupForm.js +33 -10
  96. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
  97. package/lib/esm/components/GroupHeader/GroupHeader.js +55 -13
  98. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +40 -7
  99. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +33 -11
  100. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +74 -0
  101. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +218 -0
  102. package/lib/esm/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
  103. package/lib/esm/components/GroupInvitedWidget/Skeleton.js +34 -0
  104. package/lib/esm/components/GroupInvitedWidget/constants.d.ts +1 -0
  105. package/lib/esm/components/GroupInvitedWidget/constants.js +1 -0
  106. package/lib/esm/components/GroupInvitedWidget/index.d.ts +4 -0
  107. package/lib/esm/components/GroupInvitedWidget/index.js +4 -0
  108. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  109. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +9 -4
  110. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +26 -5
  111. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
  112. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
  113. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  114. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +142 -0
  115. package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
  116. package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
  117. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  118. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
  119. package/lib/esm/components/Groups/Groups.d.ts +19 -16
  120. package/lib/esm/components/Groups/Groups.js +90 -91
  121. package/lib/esm/components/Groups/Skeleton.d.ts +4 -0
  122. package/lib/esm/components/Groups/Skeleton.js +2 -2
  123. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  124. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +1 -1
  125. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
  126. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +13 -6
  127. package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
  128. package/lib/esm/components/Notification/Group/Group.js +75 -0
  129. package/lib/esm/components/Notification/Group/index.d.ts +3 -0
  130. package/lib/esm/components/Notification/Group/index.js +2 -0
  131. package/lib/esm/components/Notification/Notification.js +31 -1
  132. package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  133. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  134. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +13 -8
  135. package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  136. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  137. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
  138. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  139. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +47 -22
  140. package/lib/esm/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +7 -1
  141. package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  142. package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
  143. package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
  144. package/lib/esm/components/User/User.d.ts +6 -1
  145. package/lib/esm/components/User/User.js +5 -4
  146. package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
  147. package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.js +42 -0
  148. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
  149. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +180 -0
  150. package/lib/esm/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
  151. package/lib/esm/components/UserSubscribedGroupsWidget/constants.js +1 -0
  152. package/lib/esm/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
  153. package/lib/esm/components/UserSubscribedGroupsWidget/index.js +4 -0
  154. package/lib/esm/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
  155. package/lib/esm/constants/PubSub.d.ts +28 -0
  156. package/lib/esm/constants/PubSub.js +19 -0
  157. package/lib/esm/index.d.ts +6 -2
  158. package/lib/esm/index.js +8 -4
  159. package/lib/umd/react-ui.js +1 -1
  160. package/package.json +6 -6
@@ -1,5 +1,5 @@
1
1
  import { __rest } from "tslib";
2
- import React from 'react';
2
+ import React, { useCallback, useEffect, useRef } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { CardContent, Icon, Typography } from '@mui/material';
5
5
  import classNames from 'classnames';
@@ -8,7 +8,10 @@ import { useThemeProps } from '@mui/system';
8
8
  import { PREFIX } from './constants';
9
9
  import { FormattedMessage, useIntl } from 'react-intl';
10
10
  import { SCGroupPrivacyType } from '@selfcommunity/types';
11
+ import PubSub from 'pubsub-js';
11
12
  import { useSCFetchGroup } from '@selfcommunity/react-core';
13
+ import GroupInfoWidgetSkeleton from './Skeleton';
14
+ import { SCEventType, SCTopicType } from '../../constants/PubSub';
12
15
  const classes = {
13
16
  root: `${PREFIX}-root`,
14
17
  title: `${PREFIX}-title`,
@@ -17,6 +20,7 @@ const classes = {
17
20
  privacyTitle: `${PREFIX}-privacy-title`,
18
21
  visibility: `${PREFIX}-visibility`,
19
22
  visibilityTitle: `${PREFIX}-visibility-title`,
23
+ admin: `${PREFIX}-admin`,
20
24
  date: `${PREFIX}-date`
21
25
  };
22
26
  const Root = styled(Widget, {
@@ -59,9 +63,36 @@ export default function GroupInfoWidget(inProps) {
59
63
  });
60
64
  const { className, group, groupId, onHeightChange, onStateChange } = props, rest = __rest(props, ["className", "group", "groupId", "onHeightChange", "onStateChange"]);
61
65
  // HOOKS
62
- const { scGroup } = useSCFetchGroup({ id: groupId, group });
66
+ const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
63
67
  // INTL
64
68
  const intl = useIntl();
69
+ // REFS
70
+ const updatesSubscription = useRef(null);
71
+ /**
72
+ * Subscriber for pubsub callback
73
+ */
74
+ const onChangeGroupHandler = useCallback((_msg, data) => {
75
+ if (data && scGroup.id === data.id) {
76
+ setSCGroup(data);
77
+ }
78
+ }, [scGroup, setSCGroup]);
79
+ /**
80
+ * On mount, subscribe to receive groups updates (only edit)
81
+ */
82
+ useEffect(() => {
83
+ if (scGroup) {
84
+ updatesSubscription.current = PubSub.subscribe(`${SCTopicType.GROUP}.${SCEventType.EDIT}`, onChangeGroupHandler);
85
+ }
86
+ return () => {
87
+ updatesSubscription.current && PubSub.unsubscribe(updatesSubscription.current);
88
+ };
89
+ }, [scGroup]);
90
+ /**
91
+ * Loading group
92
+ */
93
+ if (!scGroup) {
94
+ return React.createElement(GroupInfoWidgetSkeleton, null);
95
+ }
65
96
  /**
66
97
  * Renders root object
67
98
  */
@@ -73,14 +104,14 @@ export default function GroupInfoWidget(inProps) {
73
104
  React.createElement(Typography, { component: "div", className: classes.privacy }, scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(React.Fragment, null,
74
105
  React.createElement(Typography, { className: classes.privacyTitle },
75
106
  React.createElement(Icon, null, "public"),
76
- React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" })),
107
+ React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.privacy.public", defaultMessage: "ui.groupInfoWidget.privacy.public" })),
77
108
  React.createElement(Typography, { variant: "body2" },
78
- React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
109
+ React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.privacy.public.info", defaultMessage: "ui.groupInfoWidget.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
79
110
  React.createElement(Typography, { className: classes.privacyTitle },
80
111
  React.createElement(Icon, null, "private"),
81
- React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
112
+ React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.privacy.private", defaultMessage: "ui.groupInfoWidget.privacy.private" })),
82
113
  React.createElement(Typography, { variant: "body2" },
83
- React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))),
114
+ React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.privacy.private.info", defaultMessage: "ui.groupInfoWidget.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))),
84
115
  scGroup.privacy === SCGroupPrivacyType.PRIVATE && (React.createElement(Typography, { component: "div", className: classes.visibility }, scGroup.visible ? (React.createElement(React.Fragment, null,
85
116
  React.createElement(Typography, { className: classes.visibilityTitle },
86
117
  React.createElement(Icon, null, "visibility"),
@@ -93,5 +124,7 @@ export default function GroupInfoWidget(inProps) {
93
124
  React.createElement(Typography, { variant: "body2" },
94
125
  React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))))),
95
126
  React.createElement(Typography, { variant: "body2", className: classes.date },
96
- React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })))));
127
+ React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })),
128
+ React.createElement(Typography, { variant: "body2", className: classes.admin },
129
+ React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.admin", defaultMessage: "ui.groupInfoWidget.admin", values: { b: (chunks) => React.createElement("strong", null, chunks), admin: scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by.username } })))));
97
130
  }
@@ -13,6 +13,8 @@ import Autocomplete from '@mui/material/Autocomplete';
13
13
  import User from '../User';
14
14
  import { SCOPE_SC_UI } from '../../constants/Errors';
15
15
  import { Logger } from '@selfcommunity/utils';
16
+ import { SCEventType, SCTopicType } from '../../constants/PubSub';
17
+ import PubSub from 'pubsub-js';
16
18
  const messages = defineMessages({
17
19
  placeholder: {
18
20
  id: 'ui.groupInviteButton.searchBar.placeholder',
@@ -88,12 +90,22 @@ export default function GroupInviteButton(inProps) {
88
90
  const [list, setList] = useState([]);
89
91
  const [loading, setLoading] = useState(false);
90
92
  const [invited, setInvited] = useState([]);
93
+ /**
94
+ * Notify UI when a member is invited to a group
95
+ * @param group
96
+ * @param usersInvited
97
+ */
98
+ function notifyChanges(group, usersInvited) {
99
+ if (group && usersInvited) {
100
+ PubSub.publish(`${SCTopicType.GROUP}.${SCEventType.INVITE_MEMBER}`, usersInvited);
101
+ }
102
+ }
91
103
  function convertToInvitedUsersObject(data) {
92
- const invited_users = {};
104
+ const invite_users = {};
93
105
  data.forEach((user, index) => {
94
- invited_users[`invited_users[${index}]`] = user.id;
106
+ invite_users[`invite_users[${index}]`] = user.id;
95
107
  });
96
- return invited_users;
108
+ return invite_users;
97
109
  }
98
110
  /**
99
111
  * Memoized users invited ids
@@ -108,7 +120,7 @@ export default function GroupInviteButton(inProps) {
108
120
  }, [invited]);
109
121
  // HOOKS
110
122
  const { scGroup } = useSCFetchGroup({ id: groupId, group });
111
- const canEdit = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
123
+ const isGroupAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
112
124
  // INTL
113
125
  const intl = useIntl();
114
126
  function fetchResults() {
@@ -153,11 +165,13 @@ export default function GroupInviteButton(inProps) {
153
165
  * If a value is entered in new message field, it fetches user suggested
154
166
  */
155
167
  useEffect(() => {
156
- if (value && !handleInvitations) {
168
+ if (scGroup) {
157
169
  fetchResults();
158
170
  }
159
- fetchGeneralResults();
160
- }, [value, handleInvitations]);
171
+ else {
172
+ fetchGeneralResults();
173
+ }
174
+ }, [value, scGroup]);
161
175
  /**
162
176
  * Handles dialog close
163
177
  */
@@ -180,6 +194,7 @@ export default function GroupInviteButton(inProps) {
180
194
  setIsSending(false);
181
195
  setOpen(false);
182
196
  setInvited([]);
197
+ notifyChanges(scGroup, invited);
183
198
  })
184
199
  .catch((error) => {
185
200
  setOpen(false);
@@ -223,10 +238,17 @@ export default function GroupInviteButton(inProps) {
223
238
  setInvited(invited.filter((v) => v !== option));
224
239
  setList((prev) => [...prev, option]);
225
240
  };
241
+ const filterOptions = (options, { inputValue }) => {
242
+ return options.filter((option) => {
243
+ const usernameMatch = option.username.toLowerCase().includes(inputValue.toLowerCase());
244
+ const nameMatch = option.real_name.toLowerCase().includes(inputValue.toLowerCase());
245
+ return usernameMatch || nameMatch;
246
+ });
247
+ };
226
248
  /**
227
- * If there's no authUserId, component is hidden.
249
+ * If in group edit mode and logged-in user is not also the group manager, the component is hidden.
228
250
  // */
229
- if (!canEdit) {
251
+ if (group && !isGroupAdmin) {
230
252
  return null;
231
253
  }
232
254
  /**
@@ -240,10 +262,10 @@ export default function GroupInviteButton(inProps) {
240
262
  React.createElement(Icon, { fontSize: "medium" }, "arrow_back")),
241
263
  React.createElement(Typography, { className: classes.dialogTitle },
242
264
  React.createElement(FormattedMessage, { id: "ui.groupInviteButton.dialog.title", defaultMessage: "ui.groupInviteButton.dialog.title" })),
243
- React.createElement(LoadingButton, { size: "small", color: "secondary", variant: "contained", onClick: handleSendInvitations, loading: isSending },
265
+ React.createElement(LoadingButton, { size: "small", color: "secondary", variant: "contained", onClick: handleSendInvitations, loading: isSending, disabled: !invited.length },
244
266
  React.createElement(FormattedMessage, { id: "ui.groupInviteButton.dialog.button.end", defaultMessage: "ui.groupInviteButton.dialog.button.end" }))) },
245
267
  React.createElement(Box, { className: classes.dialogContent },
246
- React.createElement(Autocomplete, { className: classes.autocomplete, loading: loading, size: "small", multiple: true, freeSolo: true, disableClearable: true, options: suggested, onChange: handleChange, onInputChange: handleInputChange, inputValue: value, value: invited, getOptionLabel: (option) => (option ? option.username : '...'), isOptionEqualToValue: (option, value) => (option ? value.id === option.id : false), renderTags: () => null, renderOption: (props, option) => (React.createElement(Box, Object.assign({ component: "li" }, props),
268
+ React.createElement(Autocomplete, { className: classes.autocomplete, loading: loading, size: "small", multiple: true, freeSolo: true, disableClearable: true, options: suggested, onChange: handleChange, onInputChange: handleInputChange, inputValue: value, filterOptions: filterOptions, value: invited, getOptionLabel: (option) => (option ? option.username : '...'), isOptionEqualToValue: (option, value) => (option ? value.id === option.id : false), renderTags: () => null, renderOption: (props, option) => (React.createElement(Box, Object.assign({ component: "li" }, props),
247
269
  React.createElement(Avatar, { alt: option.username, src: option.avatar }),
248
270
  React.createElement(Typography, { ml: 1 }, option.username))), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { variant: "outlined", placeholder: `${intl.formatMessage(messages.placeholder)}`, InputProps: Object.assign(Object.assign({}, params.InputProps), { className: classes.input, startAdornment: (React.createElement(React.Fragment, null,
249
271
  React.createElement(InputAdornment, { position: "start" },
@@ -0,0 +1,74 @@
1
+ import { WidgetProps } from '../Widget';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ import { CacheStrategies } from '@selfcommunity/utils';
4
+ import { BaseDialogProps } from '../../shared/BaseDialog';
5
+ import { VirtualScrollerItemProps } from '../../types/virtualScroller';
6
+ import { UserProps } from '../User';
7
+ export interface GroupInvitedWidgetProps extends VirtualScrollerItemProps, WidgetProps {
8
+ /**
9
+ * Group Object
10
+ * @default null
11
+ */
12
+ group?: SCGroupType;
13
+ /**
14
+ * Id of the group
15
+ * @default null
16
+ */
17
+ groupId?: number | string;
18
+ /**
19
+ * Limit the number of users to show
20
+ * @default false
21
+ */
22
+ limit?: number;
23
+ /**
24
+ * Caching strategies
25
+ * @default CacheStrategies.CACHE_FIRST
26
+ */
27
+ cacheStrategy?: CacheStrategies;
28
+ /**
29
+ * Props to spread to single user object
30
+ * @default empty object
31
+ */
32
+ UserProps?: UserProps;
33
+ /**
34
+ * Props to spread to followers users dialog
35
+ * @default {}
36
+ */
37
+ DialogProps?: BaseDialogProps;
38
+ /**
39
+ * Other props
40
+ */
41
+ [p: string]: any;
42
+ }
43
+ /**
44
+ * > API documentation for the Community-JS Group Invited Widget component. Learn about the available props and the CSS API.
45
+ *
46
+ *
47
+ * This component renders the list of the follows of the given group.
48
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupRequests)
49
+
50
+ #### Import
51
+
52
+ ```jsx
53
+ import {GroupInvitedWidget} from '@selfcommunity/react-ui';
54
+ ```
55
+
56
+ #### Component Name
57
+
58
+ The name `SCGroupInvitedWidget` can be used when providing style overrides in the theme.
59
+
60
+
61
+ #### CSS
62
+
63
+ |Rule Name|Global class|Description|
64
+ |---|---|---|
65
+ |root|.SCGroupInvitedWidget-root|Styles applied to the root element.|
66
+ |title|.SCGroupInvitedWidget-title|Styles applied to the title element.|
67
+ |noResults|.SCGroupInvitedWidget-no-results|Styles applied to no results section.|
68
+ |showMore|.SCGroupInvitedWidget-show-more|Styles applied to show more button element.|
69
+ |dialogRoot|.SCGroupInvitedWidget-dialog-root|Styles applied to the dialog root element.|
70
+ |endMessage|.SCGroupInvitedWidget-end-message|Styles applied to the end message element.|
71
+
72
+ * @param inProps
73
+ */
74
+ export default function GroupInvitedWidget(inProps: GroupInvitedWidgetProps): JSX.Element;
@@ -0,0 +1,218 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import List from '@mui/material/List';
5
+ import { Button, CardContent, ListItem, Typography, useMediaQuery, useTheme } from '@mui/material';
6
+ import Widget from '../Widget';
7
+ import { http, Endpoints, GroupService } from '@selfcommunity/api-services';
8
+ import { CacheStrategies, isInteger, Logger } from '@selfcommunity/utils';
9
+ import { SCCache, SCPreferences, useSCFetchGroup, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
10
+ import { actionWidgetTypes, dataWidgetReducer, stateWidgetInitializer } from '../../utils/widget';
11
+ import Skeleton from './Skeleton';
12
+ import { FormattedMessage } from 'react-intl';
13
+ import classNames from 'classnames';
14
+ import { SCOPE_SC_UI } from '../../constants/Errors';
15
+ import BaseDialog from '../../shared/BaseDialog';
16
+ import InfiniteScroll from '../../shared/InfiniteScroll';
17
+ import { useThemeProps } from '@mui/system';
18
+ import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
19
+ import { PREFIX } from './constants';
20
+ import User, { UserSkeleton } from '../User';
21
+ import PubSub from 'pubsub-js';
22
+ import { SCEventType, SCTopicType } from '../../constants/PubSub';
23
+ const classes = {
24
+ root: `${PREFIX}-root`,
25
+ title: `${PREFIX}-title`,
26
+ noResults: `${PREFIX}-no-results`,
27
+ showMore: `${PREFIX}-show-more`,
28
+ dialogRoot: `${PREFIX}-dialog-root`,
29
+ endMessage: `${PREFIX}-end-message`
30
+ };
31
+ const Root = styled(Widget, {
32
+ name: PREFIX,
33
+ slot: 'Root'
34
+ })(() => ({}));
35
+ const DialogRoot = styled(BaseDialog, {
36
+ name: PREFIX,
37
+ slot: 'DialogRoot'
38
+ })(() => ({}));
39
+ /**
40
+ * > API documentation for the Community-JS Group Invited Widget component. Learn about the available props and the CSS API.
41
+ *
42
+ *
43
+ * This component renders the list of the follows of the given group.
44
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupRequests)
45
+
46
+ #### Import
47
+
48
+ ```jsx
49
+ import {GroupInvitedWidget} from '@selfcommunity/react-ui';
50
+ ```
51
+
52
+ #### Component Name
53
+
54
+ The name `SCGroupInvitedWidget` can be used when providing style overrides in the theme.
55
+
56
+
57
+ #### CSS
58
+
59
+ |Rule Name|Global class|Description|
60
+ |---|---|---|
61
+ |root|.SCGroupInvitedWidget-root|Styles applied to the root element.|
62
+ |title|.SCGroupInvitedWidget-title|Styles applied to the title element.|
63
+ |noResults|.SCGroupInvitedWidget-no-results|Styles applied to no results section.|
64
+ |showMore|.SCGroupInvitedWidget-show-more|Styles applied to show more button element.|
65
+ |dialogRoot|.SCGroupInvitedWidget-dialog-root|Styles applied to the dialog root element.|
66
+ |endMessage|.SCGroupInvitedWidget-end-message|Styles applied to the end message element.|
67
+
68
+ * @param inProps
69
+ */
70
+ export default function GroupInvitedWidget(inProps) {
71
+ var _a, _b;
72
+ // PROPS
73
+ const props = useThemeProps({
74
+ props: inProps,
75
+ name: PREFIX
76
+ });
77
+ const { groupId, group, limit = 5, className, cacheStrategy = CacheStrategies.NETWORK_ONLY, onHeightChange, onStateChange, UserProps = {}, DialogProps = {} } = props, rest = __rest(props, ["groupId", "group", "limit", "className", "cacheStrategy", "onHeightChange", "onStateChange", "UserProps", "DialogProps"]);
78
+ // STATE
79
+ const [state, dispatch] = useReducer(dataWidgetReducer, {
80
+ isLoadingNext: false,
81
+ next: null,
82
+ cacheKey: SCCache.getWidgetStateCacheKey(SCCache.GROUP_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY, isInteger(groupId) ? groupId : group.id),
83
+ cacheStrategy,
84
+ visibleItems: limit
85
+ }, stateWidgetInitializer);
86
+ const [openDialog, setOpenDialog] = useState(false);
87
+ // CONTEXT
88
+ const scUserContext = useSCUser();
89
+ const scPreferencesContext = useSCPreferences();
90
+ const { scGroup } = useSCFetchGroup({ id: groupId, group });
91
+ // MEMO
92
+ const contentAvailability = useMemo(() => SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY in scPreferencesContext.preferences &&
93
+ scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value, [scPreferencesContext.preferences]);
94
+ // HOOKS
95
+ const theme = useTheme();
96
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'));
97
+ const isGroupAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
98
+ // REFS
99
+ const updatesSubscription = useRef(null);
100
+ /**
101
+ * Initialize component
102
+ * Fetch data only if the component is not initialized and it is not loading data
103
+ */
104
+ const _initComponent = useMemo(() => () => {
105
+ if (!state.initialized && !state.isLoadingNext) {
106
+ dispatch({ type: actionWidgetTypes.LOADING_NEXT });
107
+ GroupService.getGroupInvitedUsers(scGroup.id, { limit })
108
+ .then((payload) => {
109
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
110
+ })
111
+ .catch((error) => {
112
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
113
+ Logger.error(SCOPE_SC_UI, error);
114
+ });
115
+ }
116
+ }, [state.isLoadingNext, state.initialized, scGroup, limit, dispatch]);
117
+ // EFFECTS
118
+ useEffect(() => {
119
+ var _a;
120
+ let _t;
121
+ if ((contentAvailability || (!contentAvailability && ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id))) && scGroup && scUserContext.user !== undefined) {
122
+ _t = setTimeout(_initComponent);
123
+ return () => {
124
+ _t && clearTimeout(_t);
125
+ };
126
+ }
127
+ }, [scUserContext.user, contentAvailability, scGroup]);
128
+ useEffect(() => {
129
+ if (openDialog && state.next && state.results.length === limit && state.initialized) {
130
+ dispatch({ type: actionWidgetTypes.LOADING_NEXT });
131
+ GroupService.getGroupInvitedUsers(scGroup.id, { offset: limit, limit: 10 })
132
+ .then((payload) => {
133
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: payload });
134
+ })
135
+ .catch((error) => {
136
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
137
+ Logger.error(SCOPE_SC_UI, error);
138
+ });
139
+ }
140
+ }, [openDialog, state.next, state.results.length, state.initialized, limit]);
141
+ /**
142
+ * Virtual feed update
143
+ */
144
+ useEffect(() => {
145
+ onHeightChange && onHeightChange();
146
+ }, [state.results]);
147
+ useEffect(() => {
148
+ if (!scGroup || (!contentAvailability && !scUserContext.user)) {
149
+ return;
150
+ }
151
+ else if (cacheStrategy === CacheStrategies.NETWORK_ONLY) {
152
+ onStateChange && onStateChange({ cacheStrategy: CacheStrategies.CACHE_FIRST });
153
+ }
154
+ }, [scUserContext.user, scGroup, contentAvailability]);
155
+ useEffect(() => {
156
+ if (!scGroup || !scUserContext.user || !state.initialized) {
157
+ return;
158
+ }
159
+ }, []);
160
+ /**
161
+ * Subscriber for pubsub callback
162
+ */
163
+ const onChangeGroupHandler = useCallback((_msg, newInvited) => {
164
+ dispatch({
165
+ type: actionWidgetTypes.SET_RESULTS,
166
+ payload: { results: [...state.results, ...newInvited], count: state.count + newInvited.length }
167
+ });
168
+ }, [scGroup, dispatch, state.results]);
169
+ /**
170
+ * On mount, subscribe to receive groups updates (only edit)
171
+ */
172
+ useEffect(() => {
173
+ if (scGroup && state.results) {
174
+ updatesSubscription.current = PubSub.subscribe(`${SCTopicType.GROUP}.${SCEventType.INVITE_MEMBER}`, onChangeGroupHandler);
175
+ }
176
+ return () => {
177
+ updatesSubscription.current && PubSub.unsubscribe(updatesSubscription.current);
178
+ };
179
+ }, [scGroup, state.results]);
180
+ // HANDLERS
181
+ const handleNext = useMemo(() => () => {
182
+ dispatch({ type: actionWidgetTypes.LOADING_NEXT });
183
+ http
184
+ .request({
185
+ url: state.next,
186
+ method: Endpoints.getGroupInvitedUsers.method
187
+ })
188
+ .then((res) => {
189
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: res.data });
190
+ });
191
+ }, [dispatch, state.next, state.isLoadingNext, state.initialized]);
192
+ const handleToggleDialogOpen = () => {
193
+ setOpenDialog((prev) => !prev);
194
+ };
195
+ // RENDER
196
+ if ((!state.count && state.initialized) || !contentAvailability || !scGroup || !state.count || !state.results.length || !isGroupAdmin) {
197
+ return React.createElement(HiddenPlaceholder, null);
198
+ }
199
+ if (!state.initialized) {
200
+ return React.createElement(Skeleton, null);
201
+ }
202
+ const content = (React.createElement(CardContent, null,
203
+ React.createElement(Typography, { className: classes.title, variant: "h5" },
204
+ React.createElement(FormattedMessage, { id: "ui.groupInvitedWidget.title", defaultMessage: "ui.groupInvitedWidget.title" })),
205
+ React.createElement(React.Fragment, null,
206
+ React.createElement(List, null, state.results.slice(0, state.visibleItems).map((user) => (React.createElement(ListItem, { key: user.id },
207
+ React.createElement(User, { elevation: 0, actions: React.createElement(Button, { disabled: true, size: "small" },
208
+ React.createElement(FormattedMessage, { id: "ui.groupInvitedWidget.status", defaultMessage: "ui.groupInvitedWidget.status" })), user: user, userId: user.id }))))),
209
+ state.count > state.visibleItems && (React.createElement(Button, { className: classes.showMore, onClick: handleToggleDialogOpen },
210
+ React.createElement(FormattedMessage, { id: "ui.groupInvitedWidget.button.showMore", defaultMessage: "ui.groupInvitedWidget.button.showMore" })))),
211
+ openDialog && (React.createElement(DialogRoot, Object.assign({ className: classes.dialogRoot, title: React.createElement(FormattedMessage, { defaultMessage: "ui.groupInvitedWidget.dialogTitle", id: "ui.groupInvitedWidget.dialogTitle", values: { total: (_b = state === null || state === void 0 ? void 0 : state.results) === null || _b === void 0 ? void 0 : _b.length } }), onClose: handleToggleDialogOpen, open: openDialog }, DialogProps),
212
+ React.createElement(InfiniteScroll, { dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: React.createElement(UserSkeleton, Object.assign({ elevation: 0 }, UserProps)), height: isMobile ? '100%' : 400, endMessage: React.createElement(Typography, { className: classes.endMessage },
213
+ React.createElement(FormattedMessage, { id: "ui.groupInvitedWidget.noMoreResults", defaultMessage: "ui.groupInvitedWidget.noMoreResults" })) },
214
+ React.createElement(List, null, state.results.map((user) => (React.createElement(ListItem, { key: user.id },
215
+ React.createElement(User, { elevation: 0, actions: React.createElement(Button, { disabled: true, size: "small" },
216
+ React.createElement(FormattedMessage, { id: "ui.groupInvitedWidget.status", defaultMessage: "ui.groupInvitedWidget.status" })), user: user, userId: user.id }))))))))));
217
+ return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest), content));
218
+ }
@@ -0,0 +1,22 @@
1
+ import { WidgetProps } from '../Widget';
2
+ /**
3
+ * > API documentation for the Community-JS Group Invited Widget Skeleton component. Learn about the available props and the CSS API.
4
+
5
+ #### Import
6
+
7
+ ```jsx
8
+ import {GroupInvitedWidgetSkeleton} from '@selfcommunity/react-ui';
9
+ ```
10
+
11
+ #### Component Name
12
+
13
+ The name `SCGroupInvitedWidget-skeleton-root` can be used when providing style overrides in the theme.
14
+
15
+ #### CSS
16
+
17
+ |Rule Name|Global class|Description|
18
+ |---|---|---|
19
+ |root|.SCGroupInvitedWidget-skeleton-root|Styles applied to the root element.|
20
+ *
21
+ */
22
+ export default function GroupInvitedWidgetSkeleton(props: WidgetProps): JSX.Element;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { CategoryTrendingPeopleWidgetSkeleton } from '../CategoryTrendingUsersWidget';
3
+ import { styled } from '@mui/material/styles';
4
+ import { PREFIX } from './constants';
5
+ const classes = {
6
+ root: `${PREFIX}-skeleton-root`
7
+ };
8
+ const Root = styled(CategoryTrendingPeopleWidgetSkeleton, {
9
+ name: PREFIX,
10
+ slot: 'SkeletonRoot'
11
+ })(() => ({}));
12
+ /**
13
+ * > API documentation for the Community-JS Group Invited Widget Skeleton component. Learn about the available props and the CSS API.
14
+
15
+ #### Import
16
+
17
+ ```jsx
18
+ import {GroupInvitedWidgetSkeleton} from '@selfcommunity/react-ui';
19
+ ```
20
+
21
+ #### Component Name
22
+
23
+ The name `SCGroupInvitedWidget-skeleton-root` can be used when providing style overrides in the theme.
24
+
25
+ #### CSS
26
+
27
+ |Rule Name|Global class|Description|
28
+ |---|---|---|
29
+ |root|.SCGroupInvitedWidget-skeleton-root|Styles applied to the root element.|
30
+ *
31
+ */
32
+ export default function GroupInvitedWidgetSkeleton(props) {
33
+ return React.createElement(Root, Object.assign({ className: classes.root }, props));
34
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCGroupInvitedWidget";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCGroupInvitedWidget';
@@ -0,0 +1,4 @@
1
+ import GroupInvitedWidget, { GroupInvitedWidgetProps } from './GroupInvitedWidget';
2
+ import GroupInvitedWidgetSkeleton from './Skeleton';
3
+ export default GroupInvitedWidget;
4
+ export { GroupInvitedWidgetProps, GroupInvitedWidgetSkeleton };
@@ -0,0 +1,4 @@
1
+ import GroupInvitedWidget from './GroupInvitedWidget';
2
+ import GroupInvitedWidgetSkeleton from './Skeleton';
3
+ export default GroupInvitedWidget;
4
+ export { GroupInvitedWidgetSkeleton };
@@ -17,6 +17,11 @@ export interface GroupMembersButtonProps extends Pick<ButtonProps, Exclude<keyof
17
17
  * @default {}
18
18
  */
19
19
  DialogProps?: BaseDialogProps;
20
+ /**
21
+ * Hides this component
22
+ * @default false
23
+ */
24
+ autoHide?: boolean;
20
25
  /**
21
26
  * Any other properties
22
27
  */
@@ -6,8 +6,9 @@ import BaseDialog from '../../shared/BaseDialog';
6
6
  import { FormattedMessage } from 'react-intl';
7
7
  import InfiniteScroll from '../../shared/InfiniteScroll';
8
8
  import User, { UserSkeleton } from '../User';
9
- import { GroupService, Endpoints, http } from '@selfcommunity/api-services';
9
+ import { Endpoints, GroupService, http } from '@selfcommunity/api-services';
10
10
  import { useSCFetchGroup } from '@selfcommunity/react-core';
11
+ import { SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
11
12
  import AvatarGroupSkeleton from '../Skeleton/AvatarGroupSkeleton';
12
13
  import classNames from 'classnames';
13
14
  import { useThemeProps } from '@mui/system';
@@ -58,7 +59,7 @@ export default function GroupMembersButton(inProps) {
58
59
  props: inProps,
59
60
  name: PREFIX
60
61
  });
61
- const { className, groupId, group, DialogProps = {} } = props, rest = __rest(props, ["className", "groupId", "group", "DialogProps"]);
62
+ const { className, groupId, group, DialogProps = {}, autoHide = false } = props, rest = __rest(props, ["className", "groupId", "group", "DialogProps", "autoHide"]);
62
63
  // STATE
63
64
  const [loading, setLoading] = useState(true);
64
65
  const [next, setNext] = useState(null);
@@ -69,7 +70,11 @@ export default function GroupMembersButton(inProps) {
69
70
  const { scGroup } = useSCFetchGroup({ id: groupId, group });
70
71
  // FETCH FIRST FOLLOWERS
71
72
  useDeepCompareEffectNoCheck(() => {
72
- if (!scGroup) {
73
+ if (!scGroup ||
74
+ (scGroup &&
75
+ scGroup.privacy !== SCGroupPrivacyType.PUBLIC &&
76
+ scGroup.subscription_status !== SCGroupSubscriptionStatusType.SUBSCRIBED &&
77
+ autoHide)) {
73
78
  return;
74
79
  }
75
80
  if (members.length === 0) {
@@ -128,5 +133,5 @@ export default function GroupMembersButton(inProps) {
128
133
  React.createElement(InfiniteScroll, { dataLength: members.length, next: fetchMembers, hasMoreNext: next !== null || loading, loaderNext: React.createElement(UserSkeleton, { elevation: 0 }), height: isMobile ? '100%' : 400, endMessage: React.createElement(Typography, { className: classes.endMessage },
129
134
  React.createElement(FormattedMessage, { id: "ui.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" })) },
130
135
  React.createElement(List, null, members.map((member) => (React.createElement(ListItem, { key: member.id },
131
- React.createElement(User, { elevation: 0, user: member }))))))))));
136
+ React.createElement(User, { elevation: 0, user: member, onClick: handleToggleDialogOpen }))))))))));
132
137
  }