@selfcommunity/react-ui 0.7.9-alpha.31 → 0.7.9-alpha.33

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.
@@ -89,7 +89,6 @@ const Root = (0, styles_1.styled)(material_1.Box, {
89
89
  * @param inProps
90
90
  */
91
91
  function CommentObject(inProps) {
92
- var _a;
93
92
  // PROPS
94
93
  const props = (0, system_1.useThemeProps)({
95
94
  props: inProps,
@@ -99,7 +98,6 @@ function CommentObject(inProps) {
99
98
  // CONTEXT
100
99
  const scContext = (0, react_core_1.useSCContext)();
101
100
  const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
102
- const scGroupsManager = scUserContext.managers.groups;
103
101
  const scRoutingContext = (0, react_core_1.useSCRouting)();
104
102
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
105
103
  // STATE
@@ -117,21 +115,11 @@ function CommentObject(inProps) {
117
115
  cacheStrategy
118
116
  });
119
117
  const [openAlert, setOpenAlert] = (0, react_1.useState)(false);
120
- const [status, setStatus] = (0, react_1.useState)(null);
121
118
  // HANDLERS
122
119
  const handleVoteSuccess = (contribution) => {
123
120
  setObj(contribution);
124
121
  onVote && onVote(contribution);
125
122
  };
126
- /**
127
- * If the obj has a group, checks the subscription status for the authenticated user
128
- */
129
- (0, react_1.useEffect)(() => {
130
- var _a;
131
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (feedObject === null || feedObject === void 0 ? void 0 : feedObject.group)) {
132
- setStatus(scGroupsManager.subscriptionStatus(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group));
133
- }
134
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, feedObject === null || feedObject === void 0 ? void 0 : feedObject.group]);
135
123
  /**
136
124
  * Update state object
137
125
  * @param newObj
@@ -166,12 +154,6 @@ function CommentObject(inProps) {
166
154
  if (!scUserContext.user) {
167
155
  scContext.settings.handleAnonymousAction();
168
156
  }
169
- else if ((feedObject === null || feedObject === void 0 ? void 0 : feedObject.group) && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
170
- enqueueSnackbar(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
171
- variant: 'warning',
172
- autoHideDuration: 3000
173
- });
174
- }
175
157
  else {
176
158
  setReplyComment(comment);
177
159
  onOpenReply && onOpenReply(comment);
@@ -27,27 +27,15 @@ const Root = (0, styles_1.styled)(material_1.Box, {
27
27
  slot: 'ActionFollowRoot'
28
28
  })(() => ({}));
29
29
  function Follow(props) {
30
- var _a;
31
30
  // PROPS
32
31
  const { className = null, feedObjectId = null, feedObject = null, feedObjectType = types_1.SCContributionType.POST, handleFollow, iconized = true } = props, rest = tslib_1.__rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "handleFollow", "iconized"]);
33
32
  // STATE
34
33
  const { obj, setObj } = (0, react_core_1.useSCFetchFeedObject)({ id: feedObjectId, feedObject, feedObjectType });
35
34
  const [isFollowing, setIsFollowing] = (0, react_1.useState)(false);
36
- const [status, setStatus] = (0, react_1.useState)(null);
37
35
  // CONTEXT
38
36
  const scContext = (0, react_core_1.useSCContext)();
39
37
  const scUserContext = (0, react_core_1.useSCUser)();
40
- const scGroupsManager = scUserContext.managers.groups;
41
38
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
42
- /**
43
- * If the obj has a group, checks the subscription status for the authenticated user
44
- */
45
- (0, react_1.useEffect)(() => {
46
- var _a;
47
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (obj === null || obj === void 0 ? void 0 : obj.group)) {
48
- setStatus(scGroupsManager.subscriptionStatus(obj === null || obj === void 0 ? void 0 : obj.group));
49
- }
50
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, obj === null || obj === void 0 ? void 0 : obj.group]);
51
39
  /**
52
40
  * Perform follow/unfollow
53
41
  * Post, Discussion, Status
@@ -73,12 +61,6 @@ function Follow(props) {
73
61
  if (!scUserContext.user) {
74
62
  scContext.settings.handleAnonymousAction();
75
63
  }
76
- else if ((obj === null || obj === void 0 ? void 0 : obj.group) && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
77
- enqueueSnackbar(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
78
- variant: 'warning',
79
- autoHideDuration: 3000
80
- });
81
- }
82
64
  else {
83
65
  setIsFollowing(true);
84
66
  performFollow()
@@ -45,7 +45,6 @@ const Root = (0, styles_1.styled)(material_1.Box, {
45
45
  slot: 'ActionShareRoot'
46
46
  })(() => ({}));
47
47
  function Share(props) {
48
- var _a;
49
48
  // PROPS
50
49
  const { className = null, feedObjectId = null, feedObject = null, feedObjectType = types_1.SCContributionType.POST, withAction = true, withAudience = true, inlineAction = false } = props, rest = tslib_1.__rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "withAction", "withAudience", "inlineAction"]);
51
50
  // STATE
@@ -57,7 +56,6 @@ function Share(props) {
57
56
  const [composerShareProps, setComposerShareProps] = (0, react_1.useState)(null);
58
57
  const [openSharesDialog, setOpenSharesDialog] = (0, react_1.useState)(false);
59
58
  const [anchorEl, setAnchorEl] = react_1.default.useState(null);
60
- const [status, setStatus] = (0, react_1.useState)(null);
61
59
  // CONTEXT
62
60
  const scContext = (0, react_core_1.useSCContext)();
63
61
  const scRoutingContext = (0, react_core_1.useSCRouting)();
@@ -69,7 +67,6 @@ function Share(props) {
69
67
  const linkedinShareEnabled = react_core_1.SCPreferences.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED in scPreferencesContext.preferences &&
70
68
  scPreferencesContext.preferences[react_core_1.SCPreferences.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED].value;
71
69
  const scUserContext = (0, react_core_1.useSCUser)();
72
- const scGroupsManager = scUserContext.managers.groups;
73
70
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
74
71
  const domain = typeof location !== 'undefined' && location.origin ? location.origin : '';
75
72
  const url = domain + scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj));
@@ -102,15 +99,6 @@ function Share(props) {
102
99
  setObj(Object.assign({}, obj, { share_count: obj.share_count + 1 }));
103
100
  handleComposerOnClose();
104
101
  }
105
- /**
106
- * If the obj has a group, checks the subscription status for the authenticated user
107
- */
108
- (0, react_1.useEffect)(() => {
109
- var _a;
110
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (obj === null || obj === void 0 ? void 0 : obj.group)) {
111
- setStatus(scGroupsManager.subscriptionStatus(obj === null || obj === void 0 ? void 0 : obj.group));
112
- }
113
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, obj === null || obj === void 0 ? void 0 : obj.group]);
114
102
  /**
115
103
  * Performs follow/unfollow
116
104
  * Post, Discussion, Status
@@ -153,12 +141,6 @@ function Share(props) {
153
141
  autoHideDuration: 3000
154
142
  });
155
143
  }
156
- else if ((obj === null || obj === void 0 ? void 0 : obj.group) && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
157
- enqueueSnackbar(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
158
- variant: 'warning',
159
- autoHideDuration: 3000
160
- });
161
- }
162
144
  else {
163
145
  setIsSharing(true);
164
146
  performCreateMediaShare()
@@ -133,7 +133,7 @@ const Root = (0, styles_1.styled)(Widget_1.default, {
133
133
  * @param inProps
134
134
  */
135
135
  function FeedObject(inProps) {
136
- var _a, _b;
136
+ var _a;
137
137
  // PROPS
138
138
  const props = (0, system_1.useThemeProps)({
139
139
  props: inProps,
@@ -144,7 +144,6 @@ function FeedObject(inProps) {
144
144
  const scContext = (0, react_core_1.useSCContext)();
145
145
  const scRoutingContext = (0, react_core_1.useSCRouting)();
146
146
  const scUserContext = (0, react_core_1.useSCUser)();
147
- const scGroupsManager = scUserContext.managers.groups;
148
147
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
149
148
  // OBJECTS
150
149
  const { obj, setObj, error } = (0, react_core_1.useSCFetchFeedObject)({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
@@ -163,7 +162,6 @@ function FeedObject(inProps) {
163
162
  const [isReplying, setIsReplying] = (0, react_1.useState)(false);
164
163
  const [selectedActivities, setSelectedActivities] = (0, react_1.useState)(getInitialSelectedActivitiesType());
165
164
  const [expanded, setExpanded] = (0, react_1.useState)(summaryExpanded);
166
- const [status, setStatus] = (0, react_1.useState)(null);
167
165
  // INTL
168
166
  const intl = (0, react_intl_1.useIntl)();
169
167
  /**
@@ -195,15 +193,6 @@ function FeedObject(inProps) {
195
193
  }
196
194
  return feedObject_1.SCFeedObjectActivitiesType.RECENT_COMMENTS;
197
195
  }
198
- /**
199
- * If the obj has a group, checks the subscription status for the authenticated user
200
- */
201
- (0, react_1.useEffect)(() => {
202
- var _a;
203
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (feedObject === null || feedObject === void 0 ? void 0 : feedObject.group)) {
204
- setStatus(scGroupsManager.subscriptionStatus(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group));
205
- }
206
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, feedObject === null || feedObject === void 0 ? void 0 : feedObject.group]);
207
196
  /**
208
197
  * Open expanded activities
209
198
  */
@@ -361,12 +350,6 @@ function FeedObject(inProps) {
361
350
  autoHideDuration: 3000
362
351
  });
363
352
  }
364
- else if ((feedObject === null || feedObject === void 0 ? void 0 : feedObject.group) && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
365
- enqueueSnackbar(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
366
- variant: 'warning',
367
- autoHideDuration: 3000
368
- });
369
- }
370
353
  else {
371
354
  setIsReplying(true);
372
355
  performReply(comment)
@@ -464,8 +447,8 @@ function FeedObject(inProps) {
464
447
  obj.location && (react_1.default.createElement(react_1.default.Fragment, null,
465
448
  react_1.default.createElement(Bullet_1.default, null),
466
449
  react_1.default.createElement(material_1.Box, { className: classes.location },
467
- react_1.default.createElement(Icon_1.default, null, "add_location_alt"), (_b = obj.location) === null || _b === void 0 ? void 0 :
468
- _b.location))),
450
+ react_1.default.createElement(Icon_1.default, null, "add_location_alt"), (_a = obj.location) === null || _a === void 0 ? void 0 :
451
+ _a.location))),
469
452
  react_1.default.createElement(Bullet_1.default, null),
470
453
  react_1.default.createElement(material_1.Box, { className: classes.tag }, obj.addressing.length > 0 ? (react_1.default.createElement(Tags_1.default, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (react_1.default.createElement(material_1.Tooltip, { title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` },
471
454
  react_1.default.createElement(Icon_1.default, { color: "disabled", fontSize: "small" }, "groups"))) : (react_1.default.createElement(material_1.Tooltip, { title: `${intl.formatMessage(messages.visibleToAll)}` },
@@ -138,7 +138,9 @@ function GroupHeader(inProps) {
138
138
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.visible", defaultMessage: "ui.groupHeader.visibility.visible" }))) : (react_1.default.createElement(material_1.Typography, { className: classes.visibilityItem },
139
139
  react_1.default.createElement(material_1.Icon, null, "visibility_off"),
140
140
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.hidden", defaultMessage: "ui.groupHeader.visibility.hidden" })))),
141
- react_1.default.createElement(react_1.default.Fragment, null, ((scGroup && scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC) || isGroupAdmin) && (react_1.default.createElement(material_1.Box, { className: classes.members },
141
+ react_1.default.createElement(react_1.default.Fragment, null, ((scGroup && scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC) ||
142
+ scGroup.subscription_status === types_1.SCGroupSubscriptionStatusType.SUBSCRIBED ||
143
+ isGroupAdmin) && (react_1.default.createElement(material_1.Box, { className: classes.members },
142
144
  react_1.default.createElement(material_1.Typography, { className: classes.membersCounter, component: "div" },
143
145
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } })),
144
146
  react_1.default.createElement(GroupMembersButton_1.default, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps))))),
@@ -72,7 +72,11 @@ function GroupMembersButton(inProps) {
72
72
  const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
73
73
  // FETCH FIRST FOLLOWERS
74
74
  (0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
75
- if (!scGroup || (scGroup && scGroup.privacy !== types_1.SCGroupPrivacyType.PUBLIC && autoHide)) {
75
+ if (!scGroup ||
76
+ (scGroup &&
77
+ scGroup.privacy !== types_1.SCGroupPrivacyType.PUBLIC &&
78
+ scGroup.subscription_status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED &&
79
+ autoHide)) {
76
80
  return;
77
81
  }
78
82
  if (members.length === 0) {
@@ -5,7 +5,6 @@ const react_1 = tslib_1.__importStar(require("react"));
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const lab_1 = require("@mui/lab");
7
7
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
- const types_1 = require("@selfcommunity/types");
9
8
  const system_1 = require("@mui/system");
10
9
  const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
11
10
  const material_1 = require("@mui/material");
@@ -55,7 +54,6 @@ const PopperRoot = (0, styles_1.styled)(material_1.Popper, {
55
54
  * @param inProps
56
55
  */
57
56
  function VoteButton(inProps) {
58
- var _a;
59
57
  // PROPS
60
58
  const props = (0, system_1.useThemeProps)({
61
59
  props: inProps,
@@ -64,13 +62,11 @@ function VoteButton(inProps) {
64
62
  const { className, contributionId, contributionType, contribution = null, onVote } = props, rest = tslib_1.__rest(props, ["className", "contributionId", "contributionType", "contribution", "onVote"]);
65
63
  // STATE
66
64
  const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
67
- const [status, setStatus] = (0, react_1.useState)(null);
68
65
  // REF
69
66
  const timeoutRef = (0, react_1.useRef)(null);
70
67
  // CONTEXT
71
68
  const scContext = (0, react_core_1.useSCContext)();
72
69
  const scUserContext = (0, react_core_1.useSCUser)();
73
- const scGroupsManager = scUserContext.managers.groups;
74
70
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
75
71
  // HANDLERS
76
72
  const handleMouseEnter = (event) => {
@@ -85,15 +81,6 @@ function VoteButton(inProps) {
85
81
  timeoutRef.current && clearTimeout(timeoutRef.current);
86
82
  timeoutRef.current = null;
87
83
  };
88
- /**
89
- * If the obj has a group, checks the subscription status for the authenticated user
90
- */
91
- (0, react_1.useEffect)(() => {
92
- var _a;
93
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (contribution === null || contribution === void 0 ? void 0 : contribution.group)) {
94
- setStatus(scGroupsManager.subscriptionStatus(contribution === null || contribution === void 0 ? void 0 : contribution.group));
95
- }
96
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, contribution === null || contribution === void 0 ? void 0 : contribution.group]);
97
84
  /**
98
85
  * Perform vote action
99
86
  * @param reaction
@@ -108,12 +95,6 @@ function VoteButton(inProps) {
108
95
  autoHideDuration: 3000
109
96
  });
110
97
  }
111
- else if ((contribution === null || contribution === void 0 ? void 0 : contribution.group) && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
112
- enqueueSnackbar(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
113
- variant: 'warning',
114
- autoHideDuration: 3000
115
- });
116
- }
117
98
  else {
118
99
  handleVote(reaction);
119
100
  }
@@ -1,5 +1,5 @@
1
1
  import { __rest } from "tslib";
2
- import React, { useContext, useEffect, useState } from 'react';
2
+ import React, { useContext, useState } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import Widget from '../Widget';
5
5
  import { FormattedMessage } from 'react-intl';
@@ -17,7 +17,7 @@ import { getContributionHtml, getContributionType, getRouteData } from '../../ut
17
17
  import { useSnackbar } from 'notistack';
18
18
  import { useThemeProps } from '@mui/system';
19
19
  import BaseItem from '../../shared/BaseItem';
20
- import { SCContributionType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
20
+ import { SCContributionType } from '@selfcommunity/types';
21
21
  import { Endpoints, http } from '@selfcommunity/api-services';
22
22
  import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
23
23
  import { Link, SCCache, SCRoutes, SCUserContext, UserUtils, useSCContext, useSCFetchCommentObject, useSCFetchCommentObjects, useSCRouting } from '@selfcommunity/react-core';
@@ -87,7 +87,6 @@ const Root = styled(Box, {
87
87
  * @param inProps
88
88
  */
89
89
  export default function CommentObject(inProps) {
90
- var _a;
91
90
  // PROPS
92
91
  const props = useThemeProps({
93
92
  props: inProps,
@@ -97,7 +96,6 @@ export default function CommentObject(inProps) {
97
96
  // CONTEXT
98
97
  const scContext = useSCContext();
99
98
  const scUserContext = useContext(SCUserContext);
100
- const scGroupsManager = scUserContext.managers.groups;
101
99
  const scRoutingContext = useSCRouting();
102
100
  const { enqueueSnackbar } = useSnackbar();
103
101
  // STATE
@@ -115,21 +113,11 @@ export default function CommentObject(inProps) {
115
113
  cacheStrategy
116
114
  });
117
115
  const [openAlert, setOpenAlert] = useState(false);
118
- const [status, setStatus] = useState(null);
119
116
  // HANDLERS
120
117
  const handleVoteSuccess = (contribution) => {
121
118
  setObj(contribution);
122
119
  onVote && onVote(contribution);
123
120
  };
124
- /**
125
- * If the obj has a group, checks the subscription status for the authenticated user
126
- */
127
- useEffect(() => {
128
- var _a;
129
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (feedObject === null || feedObject === void 0 ? void 0 : feedObject.group)) {
130
- setStatus(scGroupsManager.subscriptionStatus(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group));
131
- }
132
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, feedObject === null || feedObject === void 0 ? void 0 : feedObject.group]);
133
121
  /**
134
122
  * Update state object
135
123
  * @param newObj
@@ -164,12 +152,6 @@ export default function CommentObject(inProps) {
164
152
  if (!scUserContext.user) {
165
153
  scContext.settings.handleAnonymousAction();
166
154
  }
167
- else if ((feedObject === null || feedObject === void 0 ? void 0 : feedObject.group) && status !== SCGroupSubscriptionStatusType.SUBSCRIBED) {
168
- enqueueSnackbar(React.createElement(FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
169
- variant: 'warning',
170
- autoHideDuration: 3000
171
- });
172
- }
173
155
  else {
174
156
  setReplyComment(comment);
175
157
  onOpenReply && onOpenReply(comment);
@@ -1,5 +1,5 @@
1
1
  import { __rest } from "tslib";
2
- import React, { useEffect, useMemo, useState } from 'react';
2
+ import React, { useMemo, useState } from 'react';
3
3
  import { FormattedMessage } from 'react-intl';
4
4
  import LoadingButton from '@mui/lab/LoadingButton';
5
5
  import { styled } from '@mui/material/styles';
@@ -8,7 +8,7 @@ import { SCOPE_SC_UI } from '../../../../constants/Errors';
8
8
  import classNames from 'classnames';
9
9
  import { useSnackbar } from 'notistack';
10
10
  import Icon from '@mui/material/Icon';
11
- import { SCContributionType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
11
+ import { SCContributionType } from '@selfcommunity/types';
12
12
  import { Endpoints, http } from '@selfcommunity/api-services';
13
13
  import { Logger } from '@selfcommunity/utils';
14
14
  import { useSCContext, useSCFetchFeedObject, useSCUser } from '@selfcommunity/react-core';
@@ -25,27 +25,15 @@ const Root = styled(Box, {
25
25
  slot: 'ActionFollowRoot'
26
26
  })(() => ({}));
27
27
  export default function Follow(props) {
28
- var _a;
29
28
  // PROPS
30
29
  const { className = null, feedObjectId = null, feedObject = null, feedObjectType = SCContributionType.POST, handleFollow, iconized = true } = props, rest = __rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "handleFollow", "iconized"]);
31
30
  // STATE
32
31
  const { obj, setObj } = useSCFetchFeedObject({ id: feedObjectId, feedObject, feedObjectType });
33
32
  const [isFollowing, setIsFollowing] = useState(false);
34
- const [status, setStatus] = useState(null);
35
33
  // CONTEXT
36
34
  const scContext = useSCContext();
37
35
  const scUserContext = useSCUser();
38
- const scGroupsManager = scUserContext.managers.groups;
39
36
  const { enqueueSnackbar } = useSnackbar();
40
- /**
41
- * If the obj has a group, checks the subscription status for the authenticated user
42
- */
43
- useEffect(() => {
44
- var _a;
45
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (obj === null || obj === void 0 ? void 0 : obj.group)) {
46
- setStatus(scGroupsManager.subscriptionStatus(obj === null || obj === void 0 ? void 0 : obj.group));
47
- }
48
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, obj === null || obj === void 0 ? void 0 : obj.group]);
49
37
  /**
50
38
  * Perform follow/unfollow
51
39
  * Post, Discussion, Status
@@ -71,12 +59,6 @@ export default function Follow(props) {
71
59
  if (!scUserContext.user) {
72
60
  scContext.settings.handleAnonymousAction();
73
61
  }
74
- else if ((obj === null || obj === void 0 ? void 0 : obj.group) && status !== SCGroupSubscriptionStatusType.SUBSCRIBED) {
75
- enqueueSnackbar(React.createElement(FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
76
- variant: 'warning',
77
- autoHideDuration: 3000
78
- });
79
- }
80
62
  else {
81
63
  setIsFollowing(true);
82
64
  performFollow()
@@ -1,5 +1,5 @@
1
1
  import { __rest } from "tslib";
2
- import React, { useContext, useEffect, useMemo, useState } from 'react';
2
+ import React, { useContext, useMemo, useState } from 'react';
3
3
  import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
4
4
  import Icon from '@mui/material/Icon';
5
5
  import LoadingButton from '@mui/lab/LoadingButton';
@@ -13,7 +13,7 @@ import { SCOPE_SC_UI } from '../../../../constants/Errors';
13
13
  import classNames from 'classnames';
14
14
  import { useSnackbar } from 'notistack';
15
15
  import Skeleton from '@mui/material/Skeleton';
16
- import { SCContributionType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
16
+ import { SCContributionType } from '@selfcommunity/types';
17
17
  import { Endpoints, http } from '@selfcommunity/api-services';
18
18
  import { copyTextToClipboard, Logger } from '@selfcommunity/utils';
19
19
  import { SCPreferences, SCPreferencesContext, UserUtils, useSCContext, useSCFetchFeedObject, useSCRouting, useSCUser } from '@selfcommunity/react-core';
@@ -43,7 +43,6 @@ const Root = styled(Box, {
43
43
  slot: 'ActionShareRoot'
44
44
  })(() => ({}));
45
45
  export default function Share(props) {
46
- var _a;
47
46
  // PROPS
48
47
  const { className = null, feedObjectId = null, feedObject = null, feedObjectType = SCContributionType.POST, withAction = true, withAudience = true, inlineAction = false } = props, rest = __rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "withAction", "withAudience", "inlineAction"]);
49
48
  // STATE
@@ -55,7 +54,6 @@ export default function Share(props) {
55
54
  const [composerShareProps, setComposerShareProps] = useState(null);
56
55
  const [openSharesDialog, setOpenSharesDialog] = useState(false);
57
56
  const [anchorEl, setAnchorEl] = React.useState(null);
58
- const [status, setStatus] = useState(null);
59
57
  // CONTEXT
60
58
  const scContext = useSCContext();
61
59
  const scRoutingContext = useSCRouting();
@@ -67,7 +65,6 @@ export default function Share(props) {
67
65
  const linkedinShareEnabled = SCPreferences.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED in scPreferencesContext.preferences &&
68
66
  scPreferencesContext.preferences[SCPreferences.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED].value;
69
67
  const scUserContext = useSCUser();
70
- const scGroupsManager = scUserContext.managers.groups;
71
68
  const { enqueueSnackbar } = useSnackbar();
72
69
  const domain = typeof location !== 'undefined' && location.origin ? location.origin : '';
73
70
  const url = domain + scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj));
@@ -100,15 +97,6 @@ export default function Share(props) {
100
97
  setObj(Object.assign({}, obj, { share_count: obj.share_count + 1 }));
101
98
  handleComposerOnClose();
102
99
  }
103
- /**
104
- * If the obj has a group, checks the subscription status for the authenticated user
105
- */
106
- useEffect(() => {
107
- var _a;
108
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (obj === null || obj === void 0 ? void 0 : obj.group)) {
109
- setStatus(scGroupsManager.subscriptionStatus(obj === null || obj === void 0 ? void 0 : obj.group));
110
- }
111
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, obj === null || obj === void 0 ? void 0 : obj.group]);
112
100
  /**
113
101
  * Performs follow/unfollow
114
102
  * Post, Discussion, Status
@@ -151,12 +139,6 @@ export default function Share(props) {
151
139
  autoHideDuration: 3000
152
140
  });
153
141
  }
154
- else if ((obj === null || obj === void 0 ? void 0 : obj.group) && status !== SCGroupSubscriptionStatusType.SUBSCRIBED) {
155
- enqueueSnackbar(React.createElement(FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
156
- variant: 'warning',
157
- autoHideDuration: 3000
158
- });
159
- }
160
142
  else {
161
143
  setIsSharing(true);
162
144
  performCreateMediaShare()
@@ -25,7 +25,7 @@ import Activities from './Activities';
25
25
  import CommentObjectReply from '../CommentObjectReply';
26
26
  import { SCOPE_SC_UI } from '../../constants/Errors';
27
27
  import { useSnackbar } from 'notistack';
28
- import { SCContributionType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
28
+ import { SCContributionType } from '@selfcommunity/types';
29
29
  import { Endpoints, http } from '@selfcommunity/api-services';
30
30
  import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
31
31
  import { catchUnauthorizedActionByBlockedUser } from '../../utils/errors';
@@ -131,7 +131,7 @@ const Root = styled(Widget, {
131
131
  * @param inProps
132
132
  */
133
133
  export default function FeedObject(inProps) {
134
- var _a, _b;
134
+ var _a;
135
135
  // PROPS
136
136
  const props = useThemeProps({
137
137
  props: inProps,
@@ -142,7 +142,6 @@ export default function FeedObject(inProps) {
142
142
  const scContext = useSCContext();
143
143
  const scRoutingContext = useSCRouting();
144
144
  const scUserContext = useSCUser();
145
- const scGroupsManager = scUserContext.managers.groups;
146
145
  const { enqueueSnackbar } = useSnackbar();
147
146
  // OBJECTS
148
147
  const { obj, setObj, error } = useSCFetchFeedObject({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
@@ -161,7 +160,6 @@ export default function FeedObject(inProps) {
161
160
  const [isReplying, setIsReplying] = useState(false);
162
161
  const [selectedActivities, setSelectedActivities] = useState(getInitialSelectedActivitiesType());
163
162
  const [expanded, setExpanded] = useState(summaryExpanded);
164
- const [status, setStatus] = useState(null);
165
163
  // INTL
166
164
  const intl = useIntl();
167
165
  /**
@@ -193,15 +191,6 @@ export default function FeedObject(inProps) {
193
191
  }
194
192
  return SCFeedObjectActivitiesType.RECENT_COMMENTS;
195
193
  }
196
- /**
197
- * If the obj has a group, checks the subscription status for the authenticated user
198
- */
199
- useEffect(() => {
200
- var _a;
201
- if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (feedObject === null || feedObject === void 0 ? void 0 : feedObject.group)) {
202
- setStatus(scGroupsManager.subscriptionStatus(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group));
203
- }
204
- }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, feedObject === null || feedObject === void 0 ? void 0 : feedObject.group]);
205
194
  /**
206
195
  * Open expanded activities
207
196
  */
@@ -359,12 +348,6 @@ export default function FeedObject(inProps) {
359
348
  autoHideDuration: 3000
360
349
  });
361
350
  }
362
- else if ((feedObject === null || feedObject === void 0 ? void 0 : feedObject.group) && status !== SCGroupSubscriptionStatusType.SUBSCRIBED) {
363
- enqueueSnackbar(React.createElement(FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
364
- variant: 'warning',
365
- autoHideDuration: 3000
366
- });
367
- }
368
351
  else {
369
352
  setIsReplying(true);
370
353
  performReply(comment)
@@ -462,8 +445,8 @@ export default function FeedObject(inProps) {
462
445
  obj.location && (React.createElement(React.Fragment, null,
463
446
  React.createElement(Bullet, null),
464
447
  React.createElement(Box, { className: classes.location },
465
- React.createElement(Icon, null, "add_location_alt"), (_b = obj.location) === null || _b === void 0 ? void 0 :
466
- _b.location))),
448
+ React.createElement(Icon, null, "add_location_alt"), (_a = obj.location) === null || _a === void 0 ? void 0 :
449
+ _a.location))),
467
450
  React.createElement(Bullet, null),
468
451
  React.createElement(Box, { className: classes.tag }, obj.addressing.length > 0 ? (React.createElement(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (React.createElement(Tooltip, { title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` },
469
452
  React.createElement(Icon, { color: "disabled", fontSize: "small" }, "groups"))) : (React.createElement(Tooltip, { title: `${intl.formatMessage(messages.visibleToAll)}` },
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
2
2
  import React, { useMemo } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { Avatar, Box, Icon, Paper, Typography } from '@mui/material';
5
- import { SCGroupPrivacyType } from '@selfcommunity/types';
5
+ import { SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
6
6
  import { SCPreferences, useSCFetchGroup, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
7
7
  import GroupHeaderSkeleton from './Skeleton';
8
8
  import classNames from 'classnames';
@@ -136,7 +136,9 @@ export default function GroupHeader(inProps) {
136
136
  React.createElement(FormattedMessage, { id: "ui.groupHeader.visibility.visible", defaultMessage: "ui.groupHeader.visibility.visible" }))) : (React.createElement(Typography, { className: classes.visibilityItem },
137
137
  React.createElement(Icon, null, "visibility_off"),
138
138
  React.createElement(FormattedMessage, { id: "ui.groupHeader.visibility.hidden", defaultMessage: "ui.groupHeader.visibility.hidden" })))),
139
- React.createElement(React.Fragment, null, ((scGroup && scGroup.privacy === SCGroupPrivacyType.PUBLIC) || isGroupAdmin) && (React.createElement(Box, { className: classes.members },
139
+ React.createElement(React.Fragment, null, ((scGroup && scGroup.privacy === SCGroupPrivacyType.PUBLIC) ||
140
+ scGroup.subscription_status === SCGroupSubscriptionStatusType.SUBSCRIBED ||
141
+ isGroupAdmin) && (React.createElement(Box, { className: classes.members },
140
142
  React.createElement(Typography, { className: classes.membersCounter, component: "div" },
141
143
  React.createElement(FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } })),
142
144
  React.createElement(GroupMembersButton, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps))))),
@@ -8,7 +8,7 @@ import InfiniteScroll from '../../shared/InfiniteScroll';
8
8
  import User, { UserSkeleton } from '../User';
9
9
  import { Endpoints, GroupService, http } from '@selfcommunity/api-services';
10
10
  import { useSCFetchGroup } from '@selfcommunity/react-core';
11
- import { SCGroupPrivacyType } from '@selfcommunity/types';
11
+ import { SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
12
12
  import AvatarGroupSkeleton from '../Skeleton/AvatarGroupSkeleton';
13
13
  import classNames from 'classnames';
14
14
  import { useThemeProps } from '@mui/system';
@@ -70,7 +70,11 @@ export default function GroupMembersButton(inProps) {
70
70
  const { scGroup } = useSCFetchGroup({ id: groupId, group });
71
71
  // FETCH FIRST FOLLOWERS
72
72
  useDeepCompareEffectNoCheck(() => {
73
- if (!scGroup || (scGroup && scGroup.privacy !== SCGroupPrivacyType.PUBLIC && autoHide)) {
73
+ if (!scGroup ||
74
+ (scGroup &&
75
+ scGroup.privacy !== SCGroupPrivacyType.PUBLIC &&
76
+ scGroup.subscription_status !== SCGroupSubscriptionStatusType.SUBSCRIBED &&
77
+ autoHide)) {
74
78
  return;
75
79
  }
76
80
  if (members.length === 0) {