@selfcommunity/react-ui 0.7.18 → 0.7.19-alpha.0

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.
@@ -74,7 +74,7 @@ function GroupSubscribeButton(inProps) {
74
74
  if (authUserId) {
75
75
  setStatus(scGroupsManager.subscriptionStatus(scGroup));
76
76
  }
77
- }, [authUserId, scGroupsManager.subscriptionStatus]);
77
+ }, [authUserId, scGroupsManager.subscriptionStatus, scGroup]);
78
78
  /**
79
79
  * Notify UI when a member is added to a group
80
80
  * @param group
@@ -120,7 +120,7 @@ function GroupSubscribeButton(inProps) {
120
120
  /**
121
121
  * Get current translated status
122
122
  */
123
- const getStatus = () => {
123
+ const getStatus = (0, react_1.useMemo)(() => {
124
124
  let _status;
125
125
  switch (status) {
126
126
  case types_1.SCGroupSubscriptionStatusType.REQUESTED:
@@ -139,10 +139,10 @@ function GroupSubscribeButton(inProps) {
139
139
  break;
140
140
  }
141
141
  return _status;
142
- };
142
+ }, [status, scGroup]);
143
143
  if (!scGroup || (isGroupAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) || (isGroupAdmin && !(user === null || user === void 0 ? void 0 : user.id))) {
144
144
  return null;
145
145
  }
146
- return (react_1.default.createElement(Root, Object.assign({ size: "small", variant: "outlined", onClick: handleSubscribeAction, loading: scUserContext.user ? scGroupsManager.isLoading(scGroup) : null, disabled: status === types_1.SCGroupSubscriptionStatusType.REQUESTED, className: (0, classnames_1.default)(classes.root, className) }, rest), isGroupAdmin ? react_1.default.createElement(react_intl_1.FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.accept", id: "ui.groupSubscribeButton.accept" }) : getStatus()));
146
+ return (react_1.default.createElement(Root, Object.assign({ size: "small", variant: "outlined", onClick: handleSubscribeAction, loading: scUserContext.user ? scGroupsManager.isLoading(scGroup) : null, disabled: status === types_1.SCGroupSubscriptionStatusType.REQUESTED, className: (0, classnames_1.default)(classes.root, className) }, rest), isGroupAdmin ? react_1.default.createElement(react_intl_1.FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.accept", id: "ui.groupSubscribeButton.accept" }) : getStatus));
147
147
  }
148
148
  exports.default = GroupSubscribeButton;
@@ -72,7 +72,7 @@ export default function GroupSubscribeButton(inProps) {
72
72
  if (authUserId) {
73
73
  setStatus(scGroupsManager.subscriptionStatus(scGroup));
74
74
  }
75
- }, [authUserId, scGroupsManager.subscriptionStatus]);
75
+ }, [authUserId, scGroupsManager.subscriptionStatus, scGroup]);
76
76
  /**
77
77
  * Notify UI when a member is added to a group
78
78
  * @param group
@@ -118,7 +118,7 @@ export default function GroupSubscribeButton(inProps) {
118
118
  /**
119
119
  * Get current translated status
120
120
  */
121
- const getStatus = () => {
121
+ const getStatus = useMemo(() => {
122
122
  let _status;
123
123
  switch (status) {
124
124
  case SCGroupSubscriptionStatusType.REQUESTED:
@@ -137,9 +137,9 @@ export default function GroupSubscribeButton(inProps) {
137
137
  break;
138
138
  }
139
139
  return _status;
140
- };
140
+ }, [status, scGroup]);
141
141
  if (!scGroup || (isGroupAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) || (isGroupAdmin && !(user === null || user === void 0 ? void 0 : user.id))) {
142
142
  return null;
143
143
  }
144
- return (React.createElement(Root, Object.assign({ size: "small", variant: "outlined", onClick: handleSubscribeAction, loading: scUserContext.user ? scGroupsManager.isLoading(scGroup) : null, disabled: status === SCGroupSubscriptionStatusType.REQUESTED, className: classNames(classes.root, className) }, rest), isGroupAdmin ? React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.accept", id: "ui.groupSubscribeButton.accept" }) : getStatus()));
144
+ return (React.createElement(Root, Object.assign({ size: "small", variant: "outlined", onClick: handleSubscribeAction, loading: scUserContext.user ? scGroupsManager.isLoading(scGroup) : null, disabled: status === SCGroupSubscriptionStatusType.REQUESTED, className: classNames(classes.root, className) }, rest), isGroupAdmin ? React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.accept", id: "ui.groupSubscribeButton.accept" }) : getStatus));
145
145
  }