@selfcommunity/react-templates 0.5.0-alpha.6 → 0.5.0-alpha.7
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/CategoryFeed/CategoryFeed.js +13 -2
- package/lib/cjs/components/EventFeed/EventFeed.js +28 -13
- package/lib/cjs/components/ExploreFeed/ExploreFeed.js +3 -2
- package/lib/cjs/components/FeedObjectDetail/FeedObjectDetail.js +4 -2
- package/lib/cjs/components/GroupFeed/GroupFeed.js +20 -5
- package/lib/cjs/components/MainFeed/MainFeed.js +3 -2
- package/lib/cjs/components/UserFeed/UserFeed.js +3 -2
- package/lib/cjs/components/UserProfile/UserProfile.js +5 -2
- package/lib/esm/components/CategoryFeed/CategoryFeed.js +16 -5
- package/lib/esm/components/EventFeed/EventFeed.js +29 -14
- package/lib/esm/components/ExploreFeed/ExploreFeed.js +3 -2
- package/lib/esm/components/FeedObjectDetail/FeedObjectDetail.js +4 -2
- package/lib/esm/components/GroupFeed/GroupFeed.js +22 -7
- package/lib/esm/components/MainFeed/MainFeed.js +3 -2
- package/lib/esm/components/UserFeed/UserFeed.js +3 -2
- package/lib/esm/components/UserProfile/UserProfile.js +5 -2
- package/lib/umd/{c473ce30406a3dad83e1.eot → 30b299174b4fa1fb9ce8.eot} +0 -0
- package/lib/umd/{b6dbec3d5816ff8baef1.woff → 3b49304a98beb1239bc7.ttf} +0 -0
- package/lib/umd/589.js +2 -0
- package/lib/umd/738.js +1 -1
- package/lib/umd/73cbb3dbfaa3ddd4df47.js +2 -0
- package/lib/umd/73cbb3dbfaa3ddd4df47.js.LICENSE.txt +21 -0
- package/lib/umd/ab247f43e550f5f6d0f8.woff2 +0 -0
- package/lib/umd/{ba74e493633796d551d1.ttf → ce10db0c87e7112cb315.woff} +0 -0
- package/lib/umd/{6158171e38cbff3c3340.svg → fff8590360ed9eed64ae.svg} +75 -69
- package/lib/umd/react-templates.js +1 -1
- package/package.json +9 -6
- package/lib/umd/60a7fdeaadfe844bc015.woff2 +0 -0
- package/lib/umd/916.js +0 -2
- /package/lib/umd/{916.js.LICENSE.txt → 589.js.LICENSE.txt} +0 -0
|
@@ -64,6 +64,7 @@ const WIDGETS = [
|
|
|
64
64
|
* @param inProps
|
|
65
65
|
*/
|
|
66
66
|
function CategoryFeed(inProps) {
|
|
67
|
+
var _a;
|
|
67
68
|
// PROPS
|
|
68
69
|
const props = (0, system_1.useThemeProps)({
|
|
69
70
|
props: inProps,
|
|
@@ -73,16 +74,23 @@ function CategoryFeed(inProps) {
|
|
|
73
74
|
// CONTEXT
|
|
74
75
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
75
76
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
77
|
+
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
76
78
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
77
79
|
// REF
|
|
78
80
|
const feedRef = (0, react_1.useRef)();
|
|
79
81
|
// Hooks
|
|
80
82
|
const { scCategory } = (0, react_core_1.useSCFetchCategory)({ id: categoryId, category });
|
|
83
|
+
const isPaymentsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
84
|
+
features &&
|
|
85
|
+
features.includes(types_1.SCFeatureName.PAYMENTS) &&
|
|
86
|
+
react_core_1.SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED in preferences &&
|
|
87
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED].value, [preferences]);
|
|
81
88
|
// HANDLERS
|
|
82
89
|
const handleComposerSuccess = (feedObject) => {
|
|
83
90
|
// Not insert if the category does not match
|
|
84
91
|
if (feedObject.categories.findIndex((c) => c.id === scCategory.id) === -1) {
|
|
85
|
-
|
|
92
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.composerIconButton.composer.success';
|
|
93
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
86
94
|
action: (snackbarId) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], react_ui_1.ContributionUtils.getRouteData(feedObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
87
95
|
variant: 'success',
|
|
88
96
|
autoHideDuration: 7000
|
|
@@ -96,7 +104,7 @@ function CategoryFeed(inProps) {
|
|
|
96
104
|
seen_by_id: [],
|
|
97
105
|
has_boost: false
|
|
98
106
|
};
|
|
99
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
107
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
100
108
|
};
|
|
101
109
|
// WIDGETS
|
|
102
110
|
const _widgets = (0, react_1.useMemo)(() => widgets.map((w) => {
|
|
@@ -108,6 +116,9 @@ function CategoryFeed(inProps) {
|
|
|
108
116
|
if (!scCategory) {
|
|
109
117
|
return (0, jsx_runtime_1.jsx)(index_1.CategoryFeedSkeleton, {});
|
|
110
118
|
}
|
|
119
|
+
else if (scCategory && isPaymentsEnabled && !scCategory.followed && !scCategory.payment_order && ((_a = scCategory.paywalls) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
120
|
+
return (0, jsx_runtime_1.jsx)(react_ui_1.HiddenPurchasableContent, {});
|
|
121
|
+
}
|
|
111
122
|
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className), ref: feedRef, endpoint: Object.assign(Object.assign({}, api_services_1.Endpoints.CategoryFeed), { url: () => api_services_1.Endpoints.CategoryFeed.url({ id: scCategory.id }) }), widgets: _widgets, ItemComponent: react_ui_1.FeedObject, itemPropsGenerator: (scUser, item) => ({
|
|
112
123
|
feedObject: item[item.type],
|
|
113
124
|
feedObjectType: item.type,
|
|
@@ -83,18 +83,33 @@ function EventFeed(inProps) {
|
|
|
83
83
|
name: constants_1.PREFIX
|
|
84
84
|
});
|
|
85
85
|
const { id = 'event_feed', className, event, eventId, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
86
|
+
// STATUS
|
|
87
|
+
const [status, setStatus] = (0, react_1.useState)(undefined);
|
|
86
88
|
// CONTEXT
|
|
87
89
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
88
90
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
91
|
+
const scEventsManager = scUserContext.managers.events;
|
|
89
92
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
93
|
+
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
90
94
|
// REF
|
|
91
95
|
const feedRef = (0, react_1.useRef)();
|
|
92
|
-
//
|
|
93
|
-
const
|
|
96
|
+
// CONST
|
|
97
|
+
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
98
|
+
(0, react_1.useEffect)(() => {
|
|
99
|
+
var _a;
|
|
100
|
+
/**
|
|
101
|
+
* Call scEventsManager.subscriptionStatus inside an effect
|
|
102
|
+
* to avoid warning rendering child during update parent state
|
|
103
|
+
*/
|
|
104
|
+
if (authUserId) {
|
|
105
|
+
setStatus((_a = scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus) === null || _a === void 0 ? void 0 : _a.call(scEventsManager, scEvent));
|
|
106
|
+
}
|
|
107
|
+
}, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent]);
|
|
94
108
|
// HANDLERS
|
|
95
109
|
const handleComposerSuccess = (feedObject) => {
|
|
96
110
|
var _a;
|
|
97
|
-
|
|
111
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.composerIconButton.composer.success';
|
|
112
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
98
113
|
action: () => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], react_ui_1.ContributionUtils.getRouteData(feedObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
99
114
|
variant: 'success',
|
|
100
115
|
autoHideDuration: 7000
|
|
@@ -107,7 +122,7 @@ function EventFeed(inProps) {
|
|
|
107
122
|
seen_by_id: [],
|
|
108
123
|
has_boost: false
|
|
109
124
|
};
|
|
110
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
125
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
111
126
|
}
|
|
112
127
|
};
|
|
113
128
|
// WIDGETS
|
|
@@ -118,17 +133,17 @@ function EventFeed(inProps) {
|
|
|
118
133
|
return w;
|
|
119
134
|
}), [widgets, scEvent]);
|
|
120
135
|
if (scUserContext.user === undefined ||
|
|
136
|
+
(scUserContext.user && status === undefined) ||
|
|
121
137
|
!scEvent ||
|
|
122
|
-
(scUserContext.user &&
|
|
123
|
-
((scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
124
|
-
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED)) ||
|
|
138
|
+
(scUserContext.user && scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC && !status) ||
|
|
125
139
|
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
|
|
126
140
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
127
141
|
}
|
|
128
142
|
else if (scEvent.privacy === types_1.SCEventPrivacyType.PRIVATE &&
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
(status === types_1.SCEventSubscriptionStatusType.INVITED ||
|
|
144
|
+
(status !== types_1.SCEventSubscriptionStatusType.SUBSCRIBED &&
|
|
145
|
+
status !== types_1.SCEventSubscriptionStatusType.GOING &&
|
|
146
|
+
status !== types_1.SCEventSubscriptionStatusType.NOT_GOING))) {
|
|
132
147
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.EventInfoWidget, { className: classes.root, event: scEvent }) })));
|
|
133
148
|
}
|
|
134
149
|
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), id: id, ref: feedRef, endpoint: Object.assign(Object.assign({}, api_services_1.Endpoints.GetEventFeed), { url: () => api_services_1.Endpoints.GetEventFeed.url({ id: scEvent.id }) }), widgets: _widgets, ItemComponent: react_ui_1.FeedObject, itemPropsGenerator: (scUser, item) => {
|
|
@@ -144,9 +159,9 @@ function EventFeed(inProps) {
|
|
|
144
159
|
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.EventInfoWidget, { className: classes.root, event: scEvent }), Boolean(scEvent &&
|
|
145
160
|
((!scUserContext.user && scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC) ||
|
|
146
161
|
(scUserContext.user &&
|
|
147
|
-
(
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
(status === types_1.SCEventSubscriptionStatusType.SUBSCRIBED ||
|
|
163
|
+
status === types_1.SCEventSubscriptionStatusType.GOING ||
|
|
164
|
+
status === types_1.SCEventSubscriptionStatusType.NOT_GOING)))) && ((0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { event: scEvent }, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "templates.eventFeed.composer.label", defaultMessage: "templates.eventFeed.composer.label" }), feedType: types_1.SCFeedTypologyType.EVENT }))] }), CustomAdvProps: { position: types_1.SCCustomAdvPosition.POSITION_FEED, groupsId: [scEvent.id] }, enabledCustomAdvPositions: [
|
|
150
165
|
types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
151
166
|
types_1.SCCustomAdvPosition.POSITION_FEED,
|
|
152
167
|
types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -90,7 +90,8 @@ function ExploreFeed(inProps) {
|
|
|
90
90
|
const feedRef = (0, react_1.useRef)();
|
|
91
91
|
// HANDLERS
|
|
92
92
|
const handleComposerSuccess = (feedObject) => {
|
|
93
|
-
|
|
93
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.inlineComposerWidget.success';
|
|
94
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
94
95
|
variant: 'success',
|
|
95
96
|
autoHideDuration: 3000
|
|
96
97
|
});
|
|
@@ -101,7 +102,7 @@ function ExploreFeed(inProps) {
|
|
|
101
102
|
seen_by_id: [],
|
|
102
103
|
has_boost: false
|
|
103
104
|
};
|
|
104
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
105
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
105
106
|
};
|
|
106
107
|
const handleAddGenerationContent = (feedObjects) => {
|
|
107
108
|
if (feedRef && feedRef.current) {
|
|
@@ -56,8 +56,10 @@ function FeedObjectDetail(inProps) {
|
|
|
56
56
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
57
57
|
const scPreferences = (0, react_core_1.useSCPreferences)();
|
|
58
58
|
// RETRIVE OBJECTS
|
|
59
|
-
const { obj,
|
|
59
|
+
const { obj, error } = (0, react_core_1.useSCFetchFeedObject)({ id: feedObjectId, feedObject, feedObjectType });
|
|
60
60
|
const [comments, setComments] = (0, react_1.useState)([]);
|
|
61
|
+
const commentsEnabled = react_core_1.SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED in scPreferences.preferences &&
|
|
62
|
+
scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED].value;
|
|
61
63
|
/**
|
|
62
64
|
* Compute preferences
|
|
63
65
|
*/
|
|
@@ -96,6 +98,6 @@ function FeedObjectDetail(inProps) {
|
|
|
96
98
|
if (!obj) {
|
|
97
99
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
98
100
|
}
|
|
99
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, Object.assign({ container: true, spacing: 2 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.FeedObject, Object.assign({}, FeedObjectProps, { feedObject: obj, template: react_ui_1.SCFeedObjectTemplateType.DETAIL, onReply: handleReply })), renderAdvertising(), (0, jsx_runtime_1.jsx)(react_ui_1.CommentsFeedObject, Object.assign({ showTitle: true, feedObject: obj, comments: comments }, CommentsFeedObjectProps), `comments_${obj.id}`)] })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: (0, jsx_runtime_1.jsx)(material_1.Hidden, Object.assign({ mdDown: true }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.StickyBox, Object.assign({}, FeedSidebarProps, { children: (0, jsx_runtime_1.jsx)(react_ui_1.RelatedFeedObjectsWidget, Object.assign({ feedObject: obj, feedObjectId: obj.id }, RelatedFeedObjectProps), `related_${obj.id}`) })) })) }))] })) })));
|
|
101
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, Object.assign({ container: true, spacing: 2 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.FeedObject, Object.assign({}, FeedObjectProps, { feedObject: obj, template: react_ui_1.SCFeedObjectTemplateType.DETAIL, onReply: handleReply })), renderAdvertising(), commentsEnabled && ((0, jsx_runtime_1.jsx)(react_ui_1.CommentsFeedObject, Object.assign({ showTitle: true, feedObject: obj, comments: comments }, CommentsFeedObjectProps), `comments_${obj.id}`))] })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: (0, jsx_runtime_1.jsx)(material_1.Hidden, Object.assign({ mdDown: true }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.StickyBox, Object.assign({}, FeedSidebarProps, { children: (0, jsx_runtime_1.jsx)(react_ui_1.RelatedFeedObjectsWidget, Object.assign({ feedObject: obj, feedObjectId: obj.id }, RelatedFeedObjectProps), `related_${obj.id}`) })) })) }))] })) })));
|
|
100
102
|
}
|
|
101
103
|
exports.default = FeedObjectDetail;
|
|
@@ -69,17 +69,32 @@ function GroupFeed(inProps) {
|
|
|
69
69
|
name: constants_1.PREFIX
|
|
70
70
|
});
|
|
71
71
|
const { id = 'group_feed', className, group, groupId, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
72
|
+
// STATUS
|
|
73
|
+
const [status, setStatus] = (0, react_1.useState)(undefined);
|
|
72
74
|
// CONTEXT
|
|
73
75
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
76
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
77
|
+
const scGroupsManager = scUserContext.managers.groups;
|
|
74
78
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
79
|
+
const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
75
80
|
// REF
|
|
76
81
|
const feedRef = (0, react_1.useRef)();
|
|
77
|
-
//
|
|
78
|
-
const
|
|
82
|
+
// CONST
|
|
83
|
+
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
84
|
+
(0, react_1.useEffect)(() => {
|
|
85
|
+
/**
|
|
86
|
+
* Call scGroupsManager.subscriptionStatus inside an effect
|
|
87
|
+
* to avoid warning rendering child during update parent state
|
|
88
|
+
*/
|
|
89
|
+
if (authUserId) {
|
|
90
|
+
setStatus(scGroupsManager.subscriptionStatus(scGroup));
|
|
91
|
+
}
|
|
92
|
+
}, [authUserId, scGroupsManager.subscriptionStatus, scGroup]);
|
|
79
93
|
// HANDLERS
|
|
80
94
|
const handleComposerSuccess = (feedObject) => {
|
|
81
95
|
var _a;
|
|
82
|
-
|
|
96
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.composerIconButton.composer.success';
|
|
97
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
83
98
|
action: (snackbarId) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], react_ui_1.ContributionUtils.getRouteData(feedObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
84
99
|
variant: 'success',
|
|
85
100
|
autoHideDuration: 7000
|
|
@@ -92,7 +107,7 @@ function GroupFeed(inProps) {
|
|
|
92
107
|
seen_by_id: [],
|
|
93
108
|
has_boost: false
|
|
94
109
|
};
|
|
95
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
110
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
96
111
|
}
|
|
97
112
|
};
|
|
98
113
|
// WIDGETS
|
|
@@ -105,7 +120,7 @@ function GroupFeed(inProps) {
|
|
|
105
120
|
if (!scGroup) {
|
|
106
121
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
107
122
|
}
|
|
108
|
-
else if (scGroup &&
|
|
123
|
+
else if (scGroup && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
|
|
109
124
|
return (0, jsx_runtime_1.jsx)(react_ui_1.GroupInfoWidget, { className: classes.root, groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id });
|
|
110
125
|
}
|
|
111
126
|
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), id: id, ref: feedRef, endpoint: Object.assign(Object.assign({}, api_services_1.Endpoints.GetGroupFeed), { url: () => api_services_1.Endpoints.GetGroupFeed.url({ id: scGroup.id }) }), widgets: _widgets, ItemComponent: react_ui_1.FeedObject, itemPropsGenerator: (scUser, item) => {
|
|
@@ -94,7 +94,8 @@ function MainFeed(inProps) {
|
|
|
94
94
|
}
|
|
95
95
|
// HANDLERS
|
|
96
96
|
const handleComposerSuccess = (feedObject) => {
|
|
97
|
-
|
|
97
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.inlineComposerWidget.success';
|
|
98
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
98
99
|
variant: 'success',
|
|
99
100
|
autoHideDuration: 3000
|
|
100
101
|
});
|
|
@@ -105,7 +106,7 @@ function MainFeed(inProps) {
|
|
|
105
106
|
seen_by_id: [],
|
|
106
107
|
has_boost: false
|
|
107
108
|
};
|
|
108
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
109
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
109
110
|
};
|
|
110
111
|
const handleAddGenerationContent = (feedObjects) => {
|
|
111
112
|
if (feedRef && feedRef.current) {
|
|
@@ -92,7 +92,8 @@ function UserFeed(inProps) {
|
|
|
92
92
|
const feedRef = (0, react_1.useRef)();
|
|
93
93
|
// HANDLERS
|
|
94
94
|
const handleComposerSuccess = (feedObject) => {
|
|
95
|
-
|
|
95
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.inlineComposerWidget.success';
|
|
96
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
96
97
|
variant: 'success',
|
|
97
98
|
autoHideDuration: 3000
|
|
98
99
|
});
|
|
@@ -103,7 +104,7 @@ function UserFeed(inProps) {
|
|
|
103
104
|
seen_by_id: [],
|
|
104
105
|
has_boost: false
|
|
105
106
|
};
|
|
106
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
107
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
107
108
|
};
|
|
108
109
|
// WIDGETS
|
|
109
110
|
const _widgets = (0, react_1.useMemo)(() => widgets.map((w) => {
|
|
@@ -185,13 +185,16 @@ function UserProfile(inProps) {
|
|
|
185
185
|
const isMe = (0, react_1.useMemo)(() => scUserContext.user && (scUser === null || scUser === void 0 ? void 0 : scUser.id) === scUserContext.user.id, [scUserContext.user, scUser]);
|
|
186
186
|
const followEnabled = (0, react_1.useMemo)(() => react_core_1.SCPreferences.CONFIGURATIONS_FOLLOW_ENABLED in scPreferencesContext.preferences &&
|
|
187
187
|
scPreferencesContext.preferences[react_core_1.SCPreferences.CONFIGURATIONS_FOLLOW_ENABLED].value, [scPreferencesContext.preferences]);
|
|
188
|
-
const
|
|
188
|
+
const connectionEnabled = react_core_1.SCPreferences.CONFIGURATIONS_CONNECTION_ENABLED in scPreferencesContext.preferences &&
|
|
189
|
+
scPreferencesContext.preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONNECTION_ENABLED].value;
|
|
190
|
+
const privateMessagingEnabled = (0, react_1.useMemo)(() => react_core_1.SCPreferences.ADDONS_PRIVATE_MESSAGES_ENABLED in scPreferencesContext.preferences &&
|
|
191
|
+
scPreferencesContext.preferences[react_core_1.SCPreferences.ADDONS_PRIVATE_MESSAGES_ENABLED].value, [scPreferencesContext.preferences]);
|
|
189
192
|
const _widgets = (0, react_1.useMemo)(() => {
|
|
190
193
|
var _a, _b;
|
|
191
194
|
if (widgets !== null) {
|
|
192
195
|
return widgets;
|
|
193
196
|
}
|
|
194
|
-
if (!scUser) {
|
|
197
|
+
if (!scUser || (!followEnabled && !connectionEnabled)) {
|
|
195
198
|
return [];
|
|
196
199
|
}
|
|
197
200
|
let _widgets = [];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useRef } from 'react';
|
|
3
3
|
import { styled } from '@mui/material';
|
|
4
|
-
import { CategoryTrendingFeedWidget, CategoryTrendingUsersWidget, ContributionUtils, Feed, FeedObject, FeedObjectSkeleton, InlineComposerWidget, SCFeedObjectTemplateType } from '@selfcommunity/react-ui';
|
|
4
|
+
import { CategoryTrendingFeedWidget, CategoryTrendingUsersWidget, ContributionUtils, Feed, FeedObject, FeedObjectSkeleton, HiddenPurchasableContent, InlineComposerWidget, SCFeedObjectTemplateType } from '@selfcommunity/react-ui';
|
|
5
5
|
import { Endpoints } from '@selfcommunity/api-services';
|
|
6
|
-
import { Link, SCRoutes, UserUtils, useSCFetchCategory, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
|
-
import { SCCustomAdvPosition, SCFeedTypologyType } from '@selfcommunity/types';
|
|
6
|
+
import { Link, SCPreferences, SCRoutes, UserUtils, useSCFetchCategory, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
|
+
import { SCCustomAdvPosition, SCFeatureName, SCFeedTypologyType } from '@selfcommunity/types';
|
|
8
8
|
import { CategoryFeedSkeleton } from './index';
|
|
9
9
|
import { useThemeProps } from '@mui/system';
|
|
10
10
|
import classNames from 'classnames';
|
|
@@ -61,6 +61,7 @@ const WIDGETS = [
|
|
|
61
61
|
* @param inProps
|
|
62
62
|
*/
|
|
63
63
|
export default function CategoryFeed(inProps) {
|
|
64
|
+
var _a;
|
|
64
65
|
// PROPS
|
|
65
66
|
const props = useThemeProps({
|
|
66
67
|
props: inProps,
|
|
@@ -70,16 +71,23 @@ export default function CategoryFeed(inProps) {
|
|
|
70
71
|
// CONTEXT
|
|
71
72
|
const scRoutingContext = useSCRouting();
|
|
72
73
|
const scUserContext = useSCUser();
|
|
74
|
+
const { preferences, features } = useSCPreferences();
|
|
73
75
|
const { enqueueSnackbar } = useSnackbar();
|
|
74
76
|
// REF
|
|
75
77
|
const feedRef = useRef();
|
|
76
78
|
// Hooks
|
|
77
79
|
const { scCategory } = useSCFetchCategory({ id: categoryId, category });
|
|
80
|
+
const isPaymentsEnabled = useMemo(() => preferences &&
|
|
81
|
+
features &&
|
|
82
|
+
features.includes(SCFeatureName.PAYMENTS) &&
|
|
83
|
+
SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED in preferences &&
|
|
84
|
+
preferences[SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED].value, [preferences]);
|
|
78
85
|
// HANDLERS
|
|
79
86
|
const handleComposerSuccess = (feedObject) => {
|
|
80
87
|
// Not insert if the category does not match
|
|
81
88
|
if (feedObject.categories.findIndex((c) => c.id === scCategory.id) === -1) {
|
|
82
|
-
|
|
89
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.composerIconButton.composer.success';
|
|
90
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
83
91
|
action: (snackbarId) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], ContributionUtils.getRouteData(feedObject)) }, { children: _jsx(FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
84
92
|
variant: 'success',
|
|
85
93
|
autoHideDuration: 7000
|
|
@@ -93,7 +101,7 @@ export default function CategoryFeed(inProps) {
|
|
|
93
101
|
seen_by_id: [],
|
|
94
102
|
has_boost: false
|
|
95
103
|
};
|
|
96
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
104
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
97
105
|
};
|
|
98
106
|
// WIDGETS
|
|
99
107
|
const _widgets = useMemo(() => widgets.map((w) => {
|
|
@@ -105,6 +113,9 @@ export default function CategoryFeed(inProps) {
|
|
|
105
113
|
if (!scCategory) {
|
|
106
114
|
return _jsx(CategoryFeedSkeleton, {});
|
|
107
115
|
}
|
|
116
|
+
else if (scCategory && isPaymentsEnabled && !scCategory.followed && !scCategory.payment_order && ((_a = scCategory.paywalls) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
117
|
+
return _jsx(HiddenPurchasableContent, {});
|
|
118
|
+
}
|
|
108
119
|
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className), ref: feedRef, endpoint: Object.assign(Object.assign({}, Endpoints.CategoryFeed), { url: () => Endpoints.CategoryFeed.url({ id: scCategory.id }) }), widgets: _widgets, ItemComponent: FeedObject, itemPropsGenerator: (scUser, item) => ({
|
|
109
120
|
feedObject: item[item.type],
|
|
110
121
|
feedObjectType: item.type,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useRef } from 'react';
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { styled, Box } from '@mui/material';
|
|
4
4
|
import { ContributionUtils, EventInfoWidget, EventLocationWidget, EventMediaWidget, EventMembersWidget, Feed, FeedObject, FeedObjectSkeleton, InlineComposerWidget, RelatedEventsWidget, SCFeedObjectTemplateType } from '@selfcommunity/react-ui';
|
|
5
5
|
import { Endpoints } from '@selfcommunity/api-services';
|
|
@@ -80,18 +80,33 @@ export default function EventFeed(inProps) {
|
|
|
80
80
|
name: PREFIX
|
|
81
81
|
});
|
|
82
82
|
const { id = 'event_feed', className, event, eventId, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
83
|
+
// STATUS
|
|
84
|
+
const [status, setStatus] = useState(undefined);
|
|
83
85
|
// CONTEXT
|
|
84
86
|
const scRoutingContext = useSCRouting();
|
|
85
87
|
const scUserContext = useSCUser();
|
|
88
|
+
const scEventsManager = scUserContext.managers.events;
|
|
86
89
|
const { enqueueSnackbar } = useSnackbar();
|
|
90
|
+
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
87
91
|
// REF
|
|
88
92
|
const feedRef = useRef();
|
|
89
|
-
//
|
|
90
|
-
const
|
|
93
|
+
// CONST
|
|
94
|
+
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
var _a;
|
|
97
|
+
/**
|
|
98
|
+
* Call scEventsManager.subscriptionStatus inside an effect
|
|
99
|
+
* to avoid warning rendering child during update parent state
|
|
100
|
+
*/
|
|
101
|
+
if (authUserId) {
|
|
102
|
+
setStatus((_a = scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus) === null || _a === void 0 ? void 0 : _a.call(scEventsManager, scEvent));
|
|
103
|
+
}
|
|
104
|
+
}, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent]);
|
|
91
105
|
// HANDLERS
|
|
92
106
|
const handleComposerSuccess = (feedObject) => {
|
|
93
107
|
var _a;
|
|
94
|
-
|
|
108
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.composerIconButton.composer.success';
|
|
109
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
95
110
|
action: () => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], ContributionUtils.getRouteData(feedObject)) }, { children: _jsx(FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
96
111
|
variant: 'success',
|
|
97
112
|
autoHideDuration: 7000
|
|
@@ -104,7 +119,7 @@ export default function EventFeed(inProps) {
|
|
|
104
119
|
seen_by_id: [],
|
|
105
120
|
has_boost: false
|
|
106
121
|
};
|
|
107
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
122
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
108
123
|
}
|
|
109
124
|
};
|
|
110
125
|
// WIDGETS
|
|
@@ -115,17 +130,17 @@ export default function EventFeed(inProps) {
|
|
|
115
130
|
return w;
|
|
116
131
|
}), [widgets, scEvent]);
|
|
117
132
|
if (scUserContext.user === undefined ||
|
|
133
|
+
(scUserContext.user && status === undefined) ||
|
|
118
134
|
!scEvent ||
|
|
119
|
-
(scUserContext.user &&
|
|
120
|
-
((scEvent.privacy === SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
121
|
-
scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED)) ||
|
|
135
|
+
(scUserContext.user && scEvent.privacy === SCEventPrivacyType.PUBLIC && !status) ||
|
|
122
136
|
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
|
|
123
137
|
return _jsx(EventFeedSkeleton, {});
|
|
124
138
|
}
|
|
125
139
|
else if (scEvent.privacy === SCEventPrivacyType.PRIVATE &&
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
(status === SCEventSubscriptionStatusType.INVITED ||
|
|
141
|
+
(status !== SCEventSubscriptionStatusType.SUBSCRIBED &&
|
|
142
|
+
status !== SCEventSubscriptionStatusType.GOING &&
|
|
143
|
+
status !== SCEventSubscriptionStatusType.NOT_GOING))) {
|
|
129
144
|
return (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(EventInfoWidget, { className: classes.root, event: scEvent }) })));
|
|
130
145
|
}
|
|
131
146
|
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className), id: id, ref: feedRef, endpoint: Object.assign(Object.assign({}, Endpoints.GetEventFeed), { url: () => Endpoints.GetEventFeed.url({ id: scEvent.id }) }), widgets: _widgets, ItemComponent: FeedObject, itemPropsGenerator: (scUser, item) => {
|
|
@@ -141,9 +156,9 @@ export default function EventFeed(inProps) {
|
|
|
141
156
|
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: _jsxs(_Fragment, { children: [_jsx(EventInfoWidget, { className: classes.root, event: scEvent }), Boolean(scEvent &&
|
|
142
157
|
((!scUserContext.user && scEvent.privacy === SCEventPrivacyType.PUBLIC) ||
|
|
143
158
|
(scUserContext.user &&
|
|
144
|
-
(
|
|
145
|
-
|
|
146
|
-
|
|
159
|
+
(status === SCEventSubscriptionStatusType.SUBSCRIBED ||
|
|
160
|
+
status === SCEventSubscriptionStatusType.GOING ||
|
|
161
|
+
status === SCEventSubscriptionStatusType.NOT_GOING)))) && (_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { event: scEvent }, label: _jsx(FormattedMessage, { id: "templates.eventFeed.composer.label", defaultMessage: "templates.eventFeed.composer.label" }), feedType: SCFeedTypologyType.EVENT }))] }), CustomAdvProps: { position: SCCustomAdvPosition.POSITION_FEED, groupsId: [scEvent.id] }, enabledCustomAdvPositions: [
|
|
147
162
|
SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
148
163
|
SCCustomAdvPosition.POSITION_FEED,
|
|
149
164
|
SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -87,7 +87,8 @@ export default function ExploreFeed(inProps) {
|
|
|
87
87
|
const feedRef = useRef();
|
|
88
88
|
// HANDLERS
|
|
89
89
|
const handleComposerSuccess = (feedObject) => {
|
|
90
|
-
|
|
90
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.inlineComposerWidget.success';
|
|
91
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
91
92
|
variant: 'success',
|
|
92
93
|
autoHideDuration: 3000
|
|
93
94
|
});
|
|
@@ -98,7 +99,7 @@ export default function ExploreFeed(inProps) {
|
|
|
98
99
|
seen_by_id: [],
|
|
99
100
|
has_boost: false
|
|
100
101
|
};
|
|
101
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
102
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
102
103
|
};
|
|
103
104
|
const handleAddGenerationContent = (feedObjects) => {
|
|
104
105
|
if (feedRef && feedRef.current) {
|
|
@@ -53,8 +53,10 @@ export default function FeedObjectDetail(inProps) {
|
|
|
53
53
|
const scUserContext = useSCUser();
|
|
54
54
|
const scPreferences = useSCPreferences();
|
|
55
55
|
// RETRIVE OBJECTS
|
|
56
|
-
const { obj,
|
|
56
|
+
const { obj, error } = useSCFetchFeedObject({ id: feedObjectId, feedObject, feedObjectType });
|
|
57
57
|
const [comments, setComments] = useState([]);
|
|
58
|
+
const commentsEnabled = SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED in scPreferences.preferences &&
|
|
59
|
+
scPreferences.preferences[SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED].value;
|
|
58
60
|
/**
|
|
59
61
|
* Compute preferences
|
|
60
62
|
*/
|
|
@@ -93,5 +95,5 @@ export default function FeedObjectDetail(inProps) {
|
|
|
93
95
|
if (!obj) {
|
|
94
96
|
return _jsx(FeedObjectDetailSkeleton, {});
|
|
95
97
|
}
|
|
96
|
-
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsxs(Grid, Object.assign({ container: true, spacing: 2 }, { children: [_jsxs(Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: [_jsx(FeedObject, Object.assign({}, FeedObjectProps, { feedObject: obj, template: SCFeedObjectTemplateType.DETAIL, onReply: handleReply })), renderAdvertising(), _jsx(CommentsFeedObject, Object.assign({ showTitle: true, feedObject: obj, comments: comments }, CommentsFeedObjectProps), `comments_${obj.id}`)] })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: _jsx(Hidden, Object.assign({ mdDown: true }, { children: _jsx(StickyBox, Object.assign({}, FeedSidebarProps, { children: _jsx(RelatedFeedObjectsWidget, Object.assign({ feedObject: obj, feedObjectId: obj.id }, RelatedFeedObjectProps), `related_${obj.id}`) })) })) }))] })) })));
|
|
98
|
+
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsxs(Grid, Object.assign({ container: true, spacing: 2 }, { children: [_jsxs(Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: [_jsx(FeedObject, Object.assign({}, FeedObjectProps, { feedObject: obj, template: SCFeedObjectTemplateType.DETAIL, onReply: handleReply })), renderAdvertising(), commentsEnabled && (_jsx(CommentsFeedObject, Object.assign({ showTitle: true, feedObject: obj, comments: comments }, CommentsFeedObjectProps), `comments_${obj.id}`))] })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: _jsx(Hidden, Object.assign({ mdDown: true }, { children: _jsx(StickyBox, Object.assign({}, FeedSidebarProps, { children: _jsx(RelatedFeedObjectsWidget, Object.assign({ feedObject: obj, feedObjectId: obj.id }, RelatedFeedObjectProps), `related_${obj.id}`) })) })) }))] })) })));
|
|
97
99
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useRef } from 'react';
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material';
|
|
4
4
|
import { ContributionUtils, Feed, FeedObject, FeedObjectSkeleton, GroupInfoWidget, GroupMembersWidget, InlineComposerWidget, SCFeedObjectTemplateType } from '@selfcommunity/react-ui';
|
|
5
5
|
import { Endpoints } from '@selfcommunity/api-services';
|
|
6
|
-
import { Link, SCRoutes, useSCFetchGroup, useSCRouting } from '@selfcommunity/react-core';
|
|
6
|
+
import { Link, SCRoutes, useSCFetchGroup, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCCustomAdvPosition, SCFeedTypologyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
|
|
8
8
|
import { useThemeProps } from '@mui/system';
|
|
9
9
|
import classNames from 'classnames';
|
|
@@ -66,17 +66,32 @@ export default function GroupFeed(inProps) {
|
|
|
66
66
|
name: PREFIX
|
|
67
67
|
});
|
|
68
68
|
const { id = 'group_feed', className, group, groupId, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
69
|
+
// STATUS
|
|
70
|
+
const [status, setStatus] = useState(undefined);
|
|
69
71
|
// CONTEXT
|
|
70
72
|
const scRoutingContext = useSCRouting();
|
|
73
|
+
const scUserContext = useSCUser();
|
|
74
|
+
const scGroupsManager = scUserContext.managers.groups;
|
|
71
75
|
const { enqueueSnackbar } = useSnackbar();
|
|
76
|
+
const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
|
|
72
77
|
// REF
|
|
73
78
|
const feedRef = useRef();
|
|
74
|
-
//
|
|
75
|
-
const
|
|
79
|
+
// CONST
|
|
80
|
+
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
/**
|
|
83
|
+
* Call scGroupsManager.subscriptionStatus inside an effect
|
|
84
|
+
* to avoid warning rendering child during update parent state
|
|
85
|
+
*/
|
|
86
|
+
if (authUserId) {
|
|
87
|
+
setStatus(scGroupsManager.subscriptionStatus(scGroup));
|
|
88
|
+
}
|
|
89
|
+
}, [authUserId, scGroupsManager.subscriptionStatus, scGroup]);
|
|
76
90
|
// HANDLERS
|
|
77
91
|
const handleComposerSuccess = (feedObject) => {
|
|
78
92
|
var _a;
|
|
79
|
-
|
|
93
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.composerIconButton.composer.success';
|
|
94
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
80
95
|
action: (snackbarId) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], ContributionUtils.getRouteData(feedObject)) }, { children: _jsx(FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
81
96
|
variant: 'success',
|
|
82
97
|
autoHideDuration: 7000
|
|
@@ -89,7 +104,7 @@ export default function GroupFeed(inProps) {
|
|
|
89
104
|
seen_by_id: [],
|
|
90
105
|
has_boost: false
|
|
91
106
|
};
|
|
92
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
107
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
93
108
|
}
|
|
94
109
|
};
|
|
95
110
|
// WIDGETS
|
|
@@ -102,7 +117,7 @@ export default function GroupFeed(inProps) {
|
|
|
102
117
|
if (!scGroup) {
|
|
103
118
|
return _jsx(GroupFeedSkeleton, {});
|
|
104
119
|
}
|
|
105
|
-
else if (scGroup &&
|
|
120
|
+
else if (scGroup && status !== SCGroupSubscriptionStatusType.SUBSCRIBED) {
|
|
106
121
|
return _jsx(GroupInfoWidget, { className: classes.root, groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id });
|
|
107
122
|
}
|
|
108
123
|
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className), id: id, ref: feedRef, endpoint: Object.assign(Object.assign({}, Endpoints.GetGroupFeed), { url: () => Endpoints.GetGroupFeed.url({ id: scGroup.id }) }), widgets: _widgets, ItemComponent: FeedObject, itemPropsGenerator: (scUser, item) => {
|
|
@@ -91,7 +91,8 @@ export default function MainFeed(inProps) {
|
|
|
91
91
|
}
|
|
92
92
|
// HANDLERS
|
|
93
93
|
const handleComposerSuccess = (feedObject) => {
|
|
94
|
-
|
|
94
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.inlineComposerWidget.success';
|
|
95
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
95
96
|
variant: 'success',
|
|
96
97
|
autoHideDuration: 3000
|
|
97
98
|
});
|
|
@@ -102,7 +103,7 @@ export default function MainFeed(inProps) {
|
|
|
102
103
|
seen_by_id: [],
|
|
103
104
|
has_boost: false
|
|
104
105
|
};
|
|
105
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
106
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
106
107
|
};
|
|
107
108
|
const handleAddGenerationContent = (feedObjects) => {
|
|
108
109
|
if (feedRef && feedRef.current) {
|
|
@@ -89,7 +89,8 @@ export default function UserFeed(inProps) {
|
|
|
89
89
|
const feedRef = useRef();
|
|
90
90
|
// HANDLERS
|
|
91
91
|
const handleComposerSuccess = (feedObject) => {
|
|
92
|
-
|
|
92
|
+
const messageId = feedObject.scheduled_at ? 'ui.composer.scheduled.success' : 'ui.inlineComposerWidget.success';
|
|
93
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: messageId, defaultMessage: messageId }), {
|
|
93
94
|
variant: 'success',
|
|
94
95
|
autoHideDuration: 3000
|
|
95
96
|
});
|
|
@@ -100,7 +101,7 @@ export default function UserFeed(inProps) {
|
|
|
100
101
|
seen_by_id: [],
|
|
101
102
|
has_boost: false
|
|
102
103
|
};
|
|
103
|
-
feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
104
|
+
!feedObject.draft && feedRef && feedRef.current && feedRef.current.addFeedData(feedUnit, true);
|
|
104
105
|
};
|
|
105
106
|
// WIDGETS
|
|
106
107
|
const _widgets = useMemo(() => widgets.map((w) => {
|