@selfcommunity/react-ui 0.10.5-payments.221 → 0.10.5-payments.223
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.
- package/lib/cjs/components/CategoriesSuggestionWidget/CategoriesSuggestionWidget.js +5 -3
- package/lib/cjs/components/CategoryFollowButton/CategoryFollowButton.js +3 -1
- package/lib/cjs/components/FeedObject/FeedObject.js +8 -3
- package/lib/cjs/components/NavigationMenuIconButton/DefaultDrawerContent.js +9 -2
- package/lib/cjs/components/UserFollowedCategoriesWidget/UserFollowedCategoriesWidget.js +9 -6
- package/lib/esm/components/CategoriesSuggestionWidget/CategoriesSuggestionWidget.js +6 -4
- package/lib/esm/components/CategoryFollowButton/CategoryFollowButton.js +4 -2
- package/lib/esm/components/FeedObject/FeedObject.js +9 -4
- package/lib/esm/components/NavigationMenuIconButton/DefaultDrawerContent.js +9 -2
- package/lib/esm/components/UserFollowedCategoriesWidget/UserFollowedCategoriesWidget.js +11 -8
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -86,8 +86,10 @@ function CategoriesSuggestionWidget(inProps) {
|
|
|
86
86
|
// HOOKS
|
|
87
87
|
const theme = (0, material_1.useTheme)();
|
|
88
88
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
89
|
+
const { preferences } = (0, react_core_1.useSCPreferences)();
|
|
89
90
|
// REFS
|
|
90
91
|
const updatesSubscription = (0, react_1.useRef)(null);
|
|
92
|
+
const categoryFollowEnabled = (0, react_1.useMemo)(() => react_core_1.SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED in preferences && preferences[react_core_1.SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED].value, [preferences]);
|
|
91
93
|
/**
|
|
92
94
|
* Initialize component
|
|
93
95
|
* Fetch data only if the component is not initialized and it is not loading data
|
|
@@ -125,13 +127,13 @@ function CategoriesSuggestionWidget(inProps) {
|
|
|
125
127
|
// EFFECTS
|
|
126
128
|
(0, react_1.useEffect)(() => {
|
|
127
129
|
let _t;
|
|
128
|
-
if (scUserContext.user) {
|
|
130
|
+
if (scUserContext.user && categoryFollowEnabled) {
|
|
129
131
|
_t = setTimeout(_initComponent);
|
|
130
132
|
return () => {
|
|
131
133
|
_t && clearTimeout(_t);
|
|
132
134
|
};
|
|
133
135
|
}
|
|
134
|
-
}, [scUserContext.user]);
|
|
136
|
+
}, [scUserContext.user, categoryFollowEnabled]);
|
|
135
137
|
(0, react_1.useEffect)(() => {
|
|
136
138
|
if (openDialog && state.next && state.results.length <= limit && state.initialized) {
|
|
137
139
|
dispatch({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
@@ -195,7 +197,7 @@ function CategoriesSuggestionWidget(inProps) {
|
|
|
195
197
|
setOpenDialog((prev) => !prev);
|
|
196
198
|
};
|
|
197
199
|
// RENDER
|
|
198
|
-
if ((autoHide && !state.count && state.initialized) || !scUserContext.user) {
|
|
200
|
+
if ((autoHide && !state.count && state.initialized) || !scUserContext.user || !categoryFollowEnabled) {
|
|
199
201
|
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
200
202
|
}
|
|
201
203
|
if (!state.initialized) {
|
|
@@ -58,6 +58,7 @@ function CategoryFollowButton(inProps) {
|
|
|
58
58
|
const scCategoriesManager = scUserContext.managers.categories;
|
|
59
59
|
// CONST
|
|
60
60
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
61
|
+
const { preferences } = (0, react_core_1.useSCPreferences)();
|
|
61
62
|
// PAYMENTS
|
|
62
63
|
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
63
64
|
const { scCategory } = (0, react_core_1.useSCFetchCategory)({
|
|
@@ -72,6 +73,7 @@ function CategoryFollowButton(inProps) {
|
|
|
72
73
|
* and the category is a paid content and the category isn't paid
|
|
73
74
|
*/
|
|
74
75
|
const isActionFollowDisabled = (0, react_1.useMemo)(() => { var _a; return disabled || (scCategory && scUserContext.user && isPaymentsEnabled && ((_a = scCategory.paywalls) === null || _a === void 0 ? void 0 : _a.length) > 0 && !scCategory.payment_order); }, [disabled, scCategory, scUserContext.user, isPaymentsEnabled]);
|
|
76
|
+
const categoryFollowEnabled = (0, react_1.useMemo)(() => react_core_1.SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED in preferences && preferences[react_core_1.SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED].value, [preferences]);
|
|
75
77
|
(0, react_1.useEffect)(() => {
|
|
76
78
|
/**
|
|
77
79
|
* Call scCategoriesManager.isFollowed inside an effect
|
|
@@ -99,7 +101,7 @@ function CategoryFollowButton(inProps) {
|
|
|
99
101
|
followCategory();
|
|
100
102
|
}
|
|
101
103
|
};
|
|
102
|
-
if (!scCategory || (scCategory && followed && scCategory.auto_follow === types_1.SCCategoryAutoFollowType.FORCED)) {
|
|
104
|
+
if (!scCategory || !categoryFollowEnabled || (scCategory && followed && scCategory.auto_follow === types_1.SCCategoryAutoFollowType.FORCED)) {
|
|
103
105
|
return null;
|
|
104
106
|
}
|
|
105
107
|
if (scCategoriesManager.isLoading(scCategory) || followed === null) {
|
|
@@ -37,6 +37,7 @@ const Composer_1 = tslib_1.__importDefault(require("../Composer"));
|
|
|
37
37
|
const FeedObjectMediaPreview_1 = tslib_1.__importDefault(require("../FeedObjectMediaPreview"));
|
|
38
38
|
const constants_1 = require("./constants");
|
|
39
39
|
const Media_1 = require("../../constants/Media");
|
|
40
|
+
const Vote_1 = tslib_1.__importDefault(require("./Actions/Vote"));
|
|
40
41
|
const messages = (0, react_intl_1.defineMessages)({
|
|
41
42
|
visibleToAll: {
|
|
42
43
|
id: 'ui.feedObject.visibleToAll',
|
|
@@ -75,7 +76,8 @@ const classes = {
|
|
|
75
76
|
replyContent: `${constants_1.PREFIX}-reply-content`,
|
|
76
77
|
activitiesSection: `${constants_1.PREFIX}-activities-section`,
|
|
77
78
|
activitiesContent: `${constants_1.PREFIX}-activities-content`,
|
|
78
|
-
followButton: `${constants_1.PREFIX}-follow-button
|
|
79
|
+
followButton: `${constants_1.PREFIX}-follow-button`,
|
|
80
|
+
vote: `${constants_1.PREFIX}-vote`
|
|
79
81
|
};
|
|
80
82
|
const Root = (0, material_1.styled)(Widget_1.default, {
|
|
81
83
|
name: constants_1.PREFIX,
|
|
@@ -146,6 +148,9 @@ function FeedObject(inProps) {
|
|
|
146
148
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
147
149
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
148
150
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
151
|
+
const { preferences } = (0, react_core_1.useSCPreferences)();
|
|
152
|
+
const allShareEnabled = react_core_1.SCPreferences.ADDONS_SHARE_POST_ENABLED in preferences && preferences[react_core_1.SCPreferences.ADDONS_SHARE_POST_ENABLED].value;
|
|
153
|
+
const commentsEnabled = react_core_1.SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED in preferences && preferences[react_core_1.SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED].value;
|
|
149
154
|
// OBJECTS
|
|
150
155
|
const { obj, setObj, error } = (0, react_core_1.useSCFetchFeedObject)({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
|
|
151
156
|
const objId = obj ? obj.id : null;
|
|
@@ -236,7 +241,7 @@ function FeedObject(inProps) {
|
|
|
236
241
|
/**
|
|
237
242
|
* Handle flag obj
|
|
238
243
|
*/
|
|
239
|
-
const handleFlag = (0, react_1.useCallback)((
|
|
244
|
+
const handleFlag = (0, react_1.useCallback)((_obj, _type, flagged) => {
|
|
240
245
|
enqueueSnackbar(flagged ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.feedObject.flagSent", defaultMessage: "ui.feedObject.flagSent" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.feedObject.flagRemoved", defaultMessage: "ui.feedObject.flagRemoved" })), {
|
|
241
246
|
autoHideDuration: 3000
|
|
242
247
|
});
|
|
@@ -430,7 +435,7 @@ function FeedObject(inProps) {
|
|
|
430
435
|
template === feedObject_1.SCFeedObjectTemplateType.SEARCH) {
|
|
431
436
|
objElement = ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: obj ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: (0, classnames_1.default)({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: classes.category }, { children: [(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [obj.group && ((0, jsx_runtime_1.jsx)(material_1.Chip, { className: classes.group, color: "secondary", size: "small", icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "groups" }), component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id)), obj.event && ((0, jsx_runtime_1.jsx)(material_1.Chip, { className: classes.event, color: "secondary", size: "small", label: obj.event.name, icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }), component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id))] }), obj.categories.map((c) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.group }, { children: (0, jsx_runtime_1.jsx)(material_1.Chip, { color: "secondary", size: "small", icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "groups" }), label: obj.group.name, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && ((0, jsx_runtime_1.jsx)(material_1.Chip, { className: classes.event, color: "secondary", size: "small", icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }), label: obj.event.name, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id)), (0, jsx_runtime_1.jsx)(material_1.CardHeader, { className: classes.header, avatar: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !obj.author.community_badge }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj)), className: classes.activityAt }, { children: (0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { component: 'span', date: obj.added_at }) })), obj.location && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.location }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "add_location_alt" }), (_a = obj.location) === null || _a === void 0 ? void 0 : _a.location] }))] })), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.tag }, { children: obj.addressing.length > 0 ? ((0, jsx_runtime_1.jsx)(Tags_1.default, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "groups" })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToAll)}` }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "public" })) }))) }))] }), action: renderHeaderAction() }), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ classes: { root: classes.content } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: template === feedObject_1.SCFeedObjectTemplateType.DETAIL ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title }))) : ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj)) }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.mediasSection }, { children: (0, jsx_runtime_1.jsx)(FeedObjectMediaPreview_1.default, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && ((0, jsx_runtime_1.jsx)(Poll_1.default, Object.assign({ visible: pollVisible ||
|
|
432
437
|
template === feedObject_1.SCFeedObjectTemplateType.DETAIL ||
|
|
433
|
-
Boolean(obj.type !== types_1.SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.infoSection }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!hideParticipantsPreview && ((0, jsx_runtime_1.jsx)(Contributors_1.default, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy }))), !_hideFollowAction && (0, jsx_runtime_1.jsx)(Follow_1.default, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) }))] })), (0, jsx_runtime_1.jsxs)(material_1.CardActions, Object.assign({ className: classes.actionsSection }, { children: [(0, jsx_runtime_1.jsx)(Actions_1.default, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideCommentAction: template === feedObject_1.SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active)), handleExpandActivities: template === feedObject_1.SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), ((template === feedObject_1.SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_h = (_g = (_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _d === void 0 ? void 0 : _d[0]) === null || _f === void 0 ? void 0 : _f.embed) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.active))) || expandedActivities) && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.replyContent }, { children: (0, jsx_runtime_1.jsx)(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) })))] })), template === feedObject_1.SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: (0, jsx_runtime_1.jsx)(material_1.CardContent, Object.assign({ className: classes.activitiesContent }, { children: (0, jsx_runtime_1.jsx)(Activities_1.default, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
438
|
+
Boolean(obj.type !== types_1.SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.infoSection }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!commentsEnabled && !allShareEnabled ? ((0, jsx_runtime_1.jsx)(Vote_1.default, { feedObjectId: feedObjectId || (feedObject === null || feedObject === void 0 ? void 0 : feedObject.id), feedObjectType: feedObjectType, feedObject: obj, inlineAction: true, onVoteAction: handleVoteSuccess, className: classes.vote })) : (!hideParticipantsPreview && ((0, jsx_runtime_1.jsx)(Contributors_1.default, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy })))), !_hideFollowAction && (0, jsx_runtime_1.jsx)(Follow_1.default, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) }))] })), (0, jsx_runtime_1.jsxs)(material_1.CardActions, Object.assign({ className: classes.actionsSection }, { children: [(0, jsx_runtime_1.jsx)(Actions_1.default, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideVoteAction: !allShareEnabled && !commentsEnabled, hideCommentAction: !commentsEnabled || template === feedObject_1.SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active)), hideShareAction: !allShareEnabled, handleExpandActivities: template === feedObject_1.SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), ((template === feedObject_1.SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_h = (_g = (_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _d === void 0 ? void 0 : _d[0]) === null || _f === void 0 ? void 0 : _f.embed) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.active))) || expandedActivities) && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.replyContent }, { children: (0, jsx_runtime_1.jsx)(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) })))] })), template === feedObject_1.SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: (0, jsx_runtime_1.jsx)(material_1.CardContent, Object.assign({ className: classes.activitiesContent }, { children: (0, jsx_runtime_1.jsx)(Activities_1.default, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
434
439
|
CommentComponentProps: Object.assign({ onDelete: handleDeleteComment, truncateContent: true, CommentsObjectComponentProps: { inPlaceLoadMoreContents: false } }, CommentComponentProps),
|
|
435
440
|
CommentObjectSkeletonProps: CommentObjectSkeletonProps
|
|
436
441
|
}, cacheStrategy: cacheStrategy }, ActivitiesProps), selectedActivities) })) }))), composerOpen && ((0, jsx_runtime_1.jsx)(Composer_1.default, { open: composerOpen, feedObject: obj, onClose: handleToggleEdit, onSuccess: handleEditSuccess, maxWidth: "sm", fullWidth: true }))] }))) : ((0, jsx_runtime_1.jsx)(Skeleton_1.default, Object.assign({ template: template }, FeedObjectSkeletonProps))) }));
|
|
@@ -59,6 +59,8 @@ function DefaultDrawerContent(inProps) {
|
|
|
59
59
|
preferences[react_core_1.SCPreferences.CONFIGURATIONS_COURSES_ENABLED].value, [preferences, features]);
|
|
60
60
|
const exploreStreamEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
61
61
|
const contentAvailable = preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
62
|
+
const showAllCategories = (0, react_1.useMemo)(() => react_core_1.SCPreferences.CONFIGURATIONS_SIDEBAR_SHOW_ALL_CATEGORIES_ENABLED in preferences &&
|
|
63
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_SIDEBAR_SHOW_ALL_CATEGORIES_ENABLED].value, [preferences]);
|
|
62
64
|
// HANDLERS
|
|
63
65
|
const handleMouseEnter = (index) => {
|
|
64
66
|
setIsHovered((prevState) => {
|
|
@@ -72,8 +74,13 @@ function DefaultDrawerContent(inProps) {
|
|
|
72
74
|
};
|
|
73
75
|
// Order categories
|
|
74
76
|
(0, react_1.useEffect)(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
if (scUserContext.user && showAllCategories) {
|
|
78
|
+
setCategoriesOrdered((0, utils_1.sortByAttr)(categories, 'order'));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
setCategoriesOrdered((0, utils_1.sortByAttr)(categories.filter((cat) => cat.followed), 'order'));
|
|
82
|
+
}
|
|
83
|
+
}, [scUserContext.user, showAllCategories, categories]);
|
|
77
84
|
const getMouseEvents = (mouseEnter, mouseLeave) => ({
|
|
78
85
|
onMouseEnter: mouseEnter,
|
|
79
86
|
onMouseLeave: mouseLeave,
|
|
@@ -70,9 +70,9 @@ function UserFollowedCategoriesWidget(inProps) {
|
|
|
70
70
|
// CONTEXT
|
|
71
71
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
72
72
|
const isMe = (0, react_1.useMemo)(() => scUserContext.user && userId === scUserContext.user.id, [scUserContext.user, userId]);
|
|
73
|
-
const
|
|
74
|
-
const contentAvailability = (0, react_1.useMemo)(() => react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY in
|
|
75
|
-
|
|
73
|
+
const { preferences } = (0, react_core_1.useSCPreferences)();
|
|
74
|
+
const contentAvailability = (0, react_1.useMemo)(() => react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY in preferences && preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value, [preferences]);
|
|
75
|
+
const categoryFollowEnabled = (0, react_1.useMemo)(() => react_core_1.SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED in preferences && preferences[react_core_1.SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED].value, [preferences]);
|
|
76
76
|
// STATE
|
|
77
77
|
const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
|
|
78
78
|
isLoadingNext: false,
|
|
@@ -108,13 +108,16 @@ function UserFollowedCategoriesWidget(inProps) {
|
|
|
108
108
|
(0, react_1.useEffect)(() => {
|
|
109
109
|
var _a;
|
|
110
110
|
let _t;
|
|
111
|
-
if ((contentAvailability || (!contentAvailability && ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id))) &&
|
|
111
|
+
if ((contentAvailability || (!contentAvailability && ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id))) &&
|
|
112
|
+
(0, utils_1.isInteger)(userId) &&
|
|
113
|
+
scUserContext.user !== undefined &&
|
|
114
|
+
categoryFollowEnabled) {
|
|
112
115
|
_t = setTimeout(_initComponent);
|
|
113
116
|
return () => {
|
|
114
117
|
_t && clearTimeout(_t);
|
|
115
118
|
};
|
|
116
119
|
}
|
|
117
|
-
}, [scUserContext.user, contentAvailability, userId]);
|
|
120
|
+
}, [scUserContext.user, contentAvailability, userId, categoryFollowEnabled]);
|
|
118
121
|
/**
|
|
119
122
|
* Virtual feed update
|
|
120
123
|
*/
|
|
@@ -151,7 +154,7 @@ function UserFollowedCategoriesWidget(inProps) {
|
|
|
151
154
|
setOpenDialog((prev) => !prev);
|
|
152
155
|
};
|
|
153
156
|
// RENDER
|
|
154
|
-
if ((autoHide && !state.count && state.initialized) || !userId) {
|
|
157
|
+
if ((autoHide && !state.count && state.initialized) || !userId || !categoryFollowEnabled) {
|
|
155
158
|
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
156
159
|
}
|
|
157
160
|
if (!state.initialized) {
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
|
4
4
|
import { Button, CardContent, List, ListItem, Typography, useMediaQuery, useTheme, styled } from '@mui/material';
|
|
5
5
|
import { Endpoints, http, SuggestionService } from '@selfcommunity/api-services';
|
|
6
|
-
import { SCCache, useSCUser } from '@selfcommunity/react-core';
|
|
6
|
+
import { SCCache, SCPreferences, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
7
7
|
import Skeleton from './Skeleton';
|
|
8
8
|
import Category, { CategorySkeleton } from '../Category';
|
|
9
9
|
import { FormattedMessage } from 'react-intl';
|
|
@@ -84,8 +84,10 @@ export default function CategoriesSuggestionWidget(inProps) {
|
|
|
84
84
|
// HOOKS
|
|
85
85
|
const theme = useTheme();
|
|
86
86
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
87
|
+
const { preferences } = useSCPreferences();
|
|
87
88
|
// REFS
|
|
88
89
|
const updatesSubscription = useRef(null);
|
|
90
|
+
const categoryFollowEnabled = useMemo(() => SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED in preferences && preferences[SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED].value, [preferences]);
|
|
89
91
|
/**
|
|
90
92
|
* Initialize component
|
|
91
93
|
* Fetch data only if the component is not initialized and it is not loading data
|
|
@@ -123,13 +125,13 @@ export default function CategoriesSuggestionWidget(inProps) {
|
|
|
123
125
|
// EFFECTS
|
|
124
126
|
useEffect(() => {
|
|
125
127
|
let _t;
|
|
126
|
-
if (scUserContext.user) {
|
|
128
|
+
if (scUserContext.user && categoryFollowEnabled) {
|
|
127
129
|
_t = setTimeout(_initComponent);
|
|
128
130
|
return () => {
|
|
129
131
|
_t && clearTimeout(_t);
|
|
130
132
|
};
|
|
131
133
|
}
|
|
132
|
-
}, [scUserContext.user]);
|
|
134
|
+
}, [scUserContext.user, categoryFollowEnabled]);
|
|
133
135
|
useEffect(() => {
|
|
134
136
|
if (openDialog && state.next && state.results.length <= limit && state.initialized) {
|
|
135
137
|
dispatch({ type: actionWidgetTypes.LOADING_NEXT });
|
|
@@ -193,7 +195,7 @@ export default function CategoriesSuggestionWidget(inProps) {
|
|
|
193
195
|
setOpenDialog((prev) => !prev);
|
|
194
196
|
};
|
|
195
197
|
// RENDER
|
|
196
|
-
if ((autoHide && !state.count && state.initialized) || !scUserContext.user) {
|
|
198
|
+
if ((autoHide && !state.count && state.initialized) || !scUserContext.user || !categoryFollowEnabled) {
|
|
197
199
|
return _jsx(HiddenPlaceholder, {});
|
|
198
200
|
}
|
|
199
201
|
if (!state.initialized) {
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { styled } from '@mui/material';
|
|
5
5
|
import { CacheStrategies, Logger } from '@selfcommunity/utils';
|
|
6
|
-
import { useSCContext, useSCFetchCategory, useSCPaymentsEnabled, useSCUser } from '@selfcommunity/react-core';
|
|
6
|
+
import { SCPreferences, useSCContext, useSCFetchCategory, useSCPaymentsEnabled, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCCategoryAutoFollowType, SCContentType } from '@selfcommunity/types';
|
|
8
8
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
9
9
|
import { LoadingButton } from '@mui/lab';
|
|
@@ -56,6 +56,7 @@ export default function CategoryFollowButton(inProps) {
|
|
|
56
56
|
const scCategoriesManager = scUserContext.managers.categories;
|
|
57
57
|
// CONST
|
|
58
58
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
59
|
+
const { preferences } = useSCPreferences();
|
|
59
60
|
// PAYMENTS
|
|
60
61
|
const { isPaymentsEnabled } = useSCPaymentsEnabled();
|
|
61
62
|
const { scCategory } = useSCFetchCategory({
|
|
@@ -70,6 +71,7 @@ export default function CategoryFollowButton(inProps) {
|
|
|
70
71
|
* and the category is a paid content and the category isn't paid
|
|
71
72
|
*/
|
|
72
73
|
const isActionFollowDisabled = useMemo(() => { var _a; return disabled || (scCategory && scUserContext.user && isPaymentsEnabled && ((_a = scCategory.paywalls) === null || _a === void 0 ? void 0 : _a.length) > 0 && !scCategory.payment_order); }, [disabled, scCategory, scUserContext.user, isPaymentsEnabled]);
|
|
74
|
+
const categoryFollowEnabled = useMemo(() => SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED in preferences && preferences[SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED].value, [preferences]);
|
|
73
75
|
useEffect(() => {
|
|
74
76
|
/**
|
|
75
77
|
* Call scCategoriesManager.isFollowed inside an effect
|
|
@@ -97,7 +99,7 @@ export default function CategoryFollowButton(inProps) {
|
|
|
97
99
|
followCategory();
|
|
98
100
|
}
|
|
99
101
|
};
|
|
100
|
-
if (!scCategory || (scCategory && followed && scCategory.auto_follow === SCCategoryAutoFollowType.FORCED)) {
|
|
102
|
+
if (!scCategory || !categoryFollowEnabled || (scCategory && followed && scCategory.auto_follow === SCCategoryAutoFollowType.FORCED)) {
|
|
101
103
|
return null;
|
|
102
104
|
}
|
|
103
105
|
if (scCategoriesManager.isLoading(scCategory) || followed === null) {
|
|
@@ -27,7 +27,7 @@ import { SCContributionType } from '@selfcommunity/types';
|
|
|
27
27
|
import { Endpoints, http } from '@selfcommunity/api-services';
|
|
28
28
|
import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
|
|
29
29
|
import { catchUnauthorizedActionByBlockedUser } from '../../utils/errors';
|
|
30
|
-
import { Link, SCCache, SCRoutes, UserUtils, useSCContext, useSCFetchFeedObject, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
30
|
+
import { Link, SCCache, SCPreferences, SCRoutes, UserUtils, useSCContext, useSCFetchFeedObject, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
31
31
|
import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
|
|
32
32
|
import UserAvatar from '../../shared/UserAvatar';
|
|
33
33
|
import { MAX_SUMMARY_LENGTH } from '../../constants/Feed';
|
|
@@ -35,6 +35,7 @@ import Composer from '../Composer';
|
|
|
35
35
|
import FeedObjectMediaPreview from '../FeedObjectMediaPreview';
|
|
36
36
|
import { PREFIX } from './constants';
|
|
37
37
|
import { MEDIA_EMBED_SC_SHARED_EVENT } from '../../constants/Media';
|
|
38
|
+
import Vote from './Actions/Vote';
|
|
38
39
|
const messages = defineMessages({
|
|
39
40
|
visibleToAll: {
|
|
40
41
|
id: 'ui.feedObject.visibleToAll',
|
|
@@ -73,7 +74,8 @@ const classes = {
|
|
|
73
74
|
replyContent: `${PREFIX}-reply-content`,
|
|
74
75
|
activitiesSection: `${PREFIX}-activities-section`,
|
|
75
76
|
activitiesContent: `${PREFIX}-activities-content`,
|
|
76
|
-
followButton: `${PREFIX}-follow-button
|
|
77
|
+
followButton: `${PREFIX}-follow-button`,
|
|
78
|
+
vote: `${PREFIX}-vote`
|
|
77
79
|
};
|
|
78
80
|
const Root = styled(Widget, {
|
|
79
81
|
name: PREFIX,
|
|
@@ -144,6 +146,9 @@ export default function FeedObject(inProps) {
|
|
|
144
146
|
const scRoutingContext = useSCRouting();
|
|
145
147
|
const scUserContext = useSCUser();
|
|
146
148
|
const { enqueueSnackbar } = useSnackbar();
|
|
149
|
+
const { preferences } = useSCPreferences();
|
|
150
|
+
const allShareEnabled = SCPreferences.ADDONS_SHARE_POST_ENABLED in preferences && preferences[SCPreferences.ADDONS_SHARE_POST_ENABLED].value;
|
|
151
|
+
const commentsEnabled = SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED in preferences && preferences[SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED].value;
|
|
147
152
|
// OBJECTS
|
|
148
153
|
const { obj, setObj, error } = useSCFetchFeedObject({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
|
|
149
154
|
const objId = obj ? obj.id : null;
|
|
@@ -234,7 +239,7 @@ export default function FeedObject(inProps) {
|
|
|
234
239
|
/**
|
|
235
240
|
* Handle flag obj
|
|
236
241
|
*/
|
|
237
|
-
const handleFlag = useCallback((
|
|
242
|
+
const handleFlag = useCallback((_obj, _type, flagged) => {
|
|
238
243
|
enqueueSnackbar(flagged ? (_jsx(FormattedMessage, { id: "ui.feedObject.flagSent", defaultMessage: "ui.feedObject.flagSent" })) : (_jsx(FormattedMessage, { id: "ui.feedObject.flagRemoved", defaultMessage: "ui.feedObject.flagRemoved" })), {
|
|
239
244
|
autoHideDuration: 3000
|
|
240
245
|
});
|
|
@@ -428,7 +433,7 @@ export default function FeedObject(inProps) {
|
|
|
428
433
|
template === SCFeedObjectTemplateType.SEARCH) {
|
|
429
434
|
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx(Chip, { className: classes.group, color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id)), obj.event && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", label: obj.event.name, icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id)), _jsx(CardHeader, { className: classes.header, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { component: 'span', date: obj.added_at }) })), obj.location && (_jsxs(_Fragment, { children: [_jsx(Bullet, {}), _jsxs(Box, Object.assign({ className: classes.location }, { children: [_jsx(Icon, { children: "add_location_alt" }), (_a = obj.location) === null || _a === void 0 ? void 0 : _a.location] }))] })), _jsx(Bullet, {}), _jsx(Box, Object.assign({ className: classes.tag }, { children: obj.addressing.length > 0 ? (_jsx(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "groups" })) }))) : (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToAll)}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "public" })) }))) }))] }), action: renderHeaderAction() }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(_Fragment, { children: template === SCFeedObjectTemplateType.DETAIL ? (_jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title }))) : (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ visible: pollVisible ||
|
|
430
435
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
431
|
-
Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), _jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy }))), !_hideFollowAction && _jsx(Follow, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) }))] })), _jsxs(CardActions, Object.assign({ className: classes.actionsSection }, { children: [_jsx(Actions, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideCommentAction: template === SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active)), handleExpandActivities: template === SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), ((template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_h = (_g = (_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _d === void 0 ? void 0 : _d[0]) === null || _f === void 0 ? void 0 : _f.embed) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.active))) || expandedActivities) && (_jsx(Box, Object.assign({ className: classes.replyContent }, { children: _jsx(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) })))] })), template === SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && (_jsx(Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: _jsx(CardContent, Object.assign({ className: classes.activitiesContent }, { children: _jsx(Activities, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
436
|
+
Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), _jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!commentsEnabled && !allShareEnabled ? (_jsx(Vote, { feedObjectId: feedObjectId || (feedObject === null || feedObject === void 0 ? void 0 : feedObject.id), feedObjectType: feedObjectType, feedObject: obj, inlineAction: true, onVoteAction: handleVoteSuccess, className: classes.vote })) : (!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy })))), !_hideFollowAction && _jsx(Follow, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) }))] })), _jsxs(CardActions, Object.assign({ className: classes.actionsSection }, { children: [_jsx(Actions, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideVoteAction: !allShareEnabled && !commentsEnabled, hideCommentAction: !commentsEnabled || template === SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active)), hideShareAction: !allShareEnabled, handleExpandActivities: template === SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), ((template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_h = (_g = (_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _d === void 0 ? void 0 : _d[0]) === null || _f === void 0 ? void 0 : _f.embed) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.active))) || expandedActivities) && (_jsx(Box, Object.assign({ className: classes.replyContent }, { children: _jsx(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) })))] })), template === SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && (_jsx(Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: _jsx(CardContent, Object.assign({ className: classes.activitiesContent }, { children: _jsx(Activities, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
432
437
|
CommentComponentProps: Object.assign({ onDelete: handleDeleteComment, truncateContent: true, CommentsObjectComponentProps: { inPlaceLoadMoreContents: false } }, CommentComponentProps),
|
|
433
438
|
CommentObjectSkeletonProps: CommentObjectSkeletonProps
|
|
434
439
|
}, cacheStrategy: cacheStrategy }, ActivitiesProps), selectedActivities) })) }))), composerOpen && (_jsx(Composer, { open: composerOpen, feedObject: obj, onClose: handleToggleEdit, onSuccess: handleEditSuccess, maxWidth: "sm", fullWidth: true }))] }))) : (_jsx(FeedObjectSkeleton, Object.assign({ template: template }, FeedObjectSkeletonProps))) }));
|
|
@@ -57,6 +57,8 @@ export default function DefaultDrawerContent(inProps) {
|
|
|
57
57
|
preferences[SCPreferences.CONFIGURATIONS_COURSES_ENABLED].value, [preferences, features]);
|
|
58
58
|
const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
59
59
|
const contentAvailable = preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
60
|
+
const showAllCategories = useMemo(() => SCPreferences.CONFIGURATIONS_SIDEBAR_SHOW_ALL_CATEGORIES_ENABLED in preferences &&
|
|
61
|
+
preferences[SCPreferences.CONFIGURATIONS_SIDEBAR_SHOW_ALL_CATEGORIES_ENABLED].value, [preferences]);
|
|
60
62
|
// HANDLERS
|
|
61
63
|
const handleMouseEnter = (index) => {
|
|
62
64
|
setIsHovered((prevState) => {
|
|
@@ -70,8 +72,13 @@ export default function DefaultDrawerContent(inProps) {
|
|
|
70
72
|
};
|
|
71
73
|
// Order categories
|
|
72
74
|
useEffect(() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
if (scUserContext.user && showAllCategories) {
|
|
76
|
+
setCategoriesOrdered(sortByAttr(categories, 'order'));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
setCategoriesOrdered(sortByAttr(categories.filter((cat) => cat.followed), 'order'));
|
|
80
|
+
}
|
|
81
|
+
}, [scUserContext.user, showAllCategories, categories]);
|
|
75
82
|
const getMouseEvents = (mouseEnter, mouseLeave) => ({
|
|
76
83
|
onMouseEnter: mouseEnter,
|
|
77
84
|
onMouseLeave: mouseLeave,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { useEffect, useMemo, useReducer, useState } from 'react';
|
|
4
4
|
import { Button, CardContent, ListItem, Typography, styled, List } from '@mui/material';
|
|
5
5
|
import { UserService } from '@selfcommunity/api-services';
|
|
6
6
|
import { CacheStrategies, isInteger, Logger } from '@selfcommunity/utils';
|
|
7
|
-
import { SCCache, SCPreferences,
|
|
7
|
+
import { SCCache, SCPreferences, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
8
8
|
import { actionWidgetTypes, dataWidgetReducer, stateWidgetInitializer } from '../../utils/widget';
|
|
9
9
|
import Category, { CategorySkeleton } from '../Category';
|
|
10
10
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
@@ -68,9 +68,9 @@ export default function UserFollowedCategoriesWidget(inProps) {
|
|
|
68
68
|
// CONTEXT
|
|
69
69
|
const scUserContext = useSCUser();
|
|
70
70
|
const isMe = useMemo(() => scUserContext.user && userId === scUserContext.user.id, [scUserContext.user, userId]);
|
|
71
|
-
const
|
|
72
|
-
const contentAvailability = useMemo(() => SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY in
|
|
73
|
-
|
|
71
|
+
const { preferences } = useSCPreferences();
|
|
72
|
+
const contentAvailability = useMemo(() => SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY in preferences && preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value, [preferences]);
|
|
73
|
+
const categoryFollowEnabled = useMemo(() => SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED in preferences && preferences[SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED].value, [preferences]);
|
|
74
74
|
// STATE
|
|
75
75
|
const [state, dispatch] = useReducer(dataWidgetReducer, {
|
|
76
76
|
isLoadingNext: false,
|
|
@@ -106,13 +106,16 @@ export default function UserFollowedCategoriesWidget(inProps) {
|
|
|
106
106
|
useEffect(() => {
|
|
107
107
|
var _a;
|
|
108
108
|
let _t;
|
|
109
|
-
if ((contentAvailability || (!contentAvailability && ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id))) &&
|
|
109
|
+
if ((contentAvailability || (!contentAvailability && ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id))) &&
|
|
110
|
+
isInteger(userId) &&
|
|
111
|
+
scUserContext.user !== undefined &&
|
|
112
|
+
categoryFollowEnabled) {
|
|
110
113
|
_t = setTimeout(_initComponent);
|
|
111
114
|
return () => {
|
|
112
115
|
_t && clearTimeout(_t);
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
|
-
}, [scUserContext.user, contentAvailability, userId]);
|
|
118
|
+
}, [scUserContext.user, contentAvailability, userId, categoryFollowEnabled]);
|
|
116
119
|
/**
|
|
117
120
|
* Virtual feed update
|
|
118
121
|
*/
|
|
@@ -149,7 +152,7 @@ export default function UserFollowedCategoriesWidget(inProps) {
|
|
|
149
152
|
setOpenDialog((prev) => !prev);
|
|
150
153
|
};
|
|
151
154
|
// RENDER
|
|
152
|
-
if ((autoHide && !state.count && state.initialized) || !userId) {
|
|
155
|
+
if ((autoHide && !state.count && state.initialized) || !userId || !categoryFollowEnabled) {
|
|
153
156
|
return _jsx(HiddenPlaceholder, {});
|
|
154
157
|
}
|
|
155
158
|
if (!state.initialized) {
|