@selfcommunity/react-ui 0.7.9-alpha.31 → 0.7.9-alpha.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/CommentObject/CommentObject.js +0 -18
- package/lib/cjs/components/FeedObject/Actions/Follow/Follow.js +0 -18
- package/lib/cjs/components/FeedObject/Actions/Share/Share.js +0 -18
- package/lib/cjs/components/FeedObject/FeedObject.js +3 -20
- package/lib/cjs/components/GroupHeader/GroupHeader.js +3 -1
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +5 -1
- package/lib/cjs/components/VoteButton/VoteButton.js +0 -19
- package/lib/esm/components/CommentObject/CommentObject.js +2 -20
- package/lib/esm/components/FeedObject/Actions/Follow/Follow.js +2 -20
- package/lib/esm/components/FeedObject/Actions/Share/Share.js +2 -20
- package/lib/esm/components/FeedObject/FeedObject.js +4 -21
- package/lib/esm/components/GroupHeader/GroupHeader.js +4 -2
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +6 -2
- package/lib/esm/components/VoteButton/VoteButton.js +1 -20
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { LoadingButton } from '@mui/lab';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { SCGroupSubscriptionStatusType } from '@selfcommunity/types';
|
|
7
6
|
import { useThemeProps } from '@mui/system';
|
|
8
7
|
import Icon from '@mui/material/Icon';
|
|
9
8
|
import { IconButton, Paper, Popper, Tooltip, useMediaQuery, useTheme } from '@mui/material';
|
|
@@ -53,7 +52,6 @@ const PopperRoot = styled(Popper, {
|
|
|
53
52
|
* @param inProps
|
|
54
53
|
*/
|
|
55
54
|
export default function VoteButton(inProps) {
|
|
56
|
-
var _a;
|
|
57
55
|
// PROPS
|
|
58
56
|
const props = useThemeProps({
|
|
59
57
|
props: inProps,
|
|
@@ -62,13 +60,11 @@ export default function VoteButton(inProps) {
|
|
|
62
60
|
const { className, contributionId, contributionType, contribution = null, onVote } = props, rest = __rest(props, ["className", "contributionId", "contributionType", "contribution", "onVote"]);
|
|
63
61
|
// STATE
|
|
64
62
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
65
|
-
const [status, setStatus] = useState(null);
|
|
66
63
|
// REF
|
|
67
64
|
const timeoutRef = useRef(null);
|
|
68
65
|
// CONTEXT
|
|
69
66
|
const scContext = useSCContext();
|
|
70
67
|
const scUserContext = useSCUser();
|
|
71
|
-
const scGroupsManager = scUserContext.managers.groups;
|
|
72
68
|
const { enqueueSnackbar } = useSnackbar();
|
|
73
69
|
// HANDLERS
|
|
74
70
|
const handleMouseEnter = (event) => {
|
|
@@ -83,15 +79,6 @@ export default function VoteButton(inProps) {
|
|
|
83
79
|
timeoutRef.current && clearTimeout(timeoutRef.current);
|
|
84
80
|
timeoutRef.current = null;
|
|
85
81
|
};
|
|
86
|
-
/**
|
|
87
|
-
* If the obj has a group, checks the subscription status for the authenticated user
|
|
88
|
-
*/
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
var _a;
|
|
91
|
-
if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (contribution === null || contribution === void 0 ? void 0 : contribution.group)) {
|
|
92
|
-
setStatus(scGroupsManager.subscriptionStatus(contribution === null || contribution === void 0 ? void 0 : contribution.group));
|
|
93
|
-
}
|
|
94
|
-
}, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, contribution === null || contribution === void 0 ? void 0 : contribution.group]);
|
|
95
82
|
/**
|
|
96
83
|
* Perform vote action
|
|
97
84
|
* @param reaction
|
|
@@ -106,12 +93,6 @@ export default function VoteButton(inProps) {
|
|
|
106
93
|
autoHideDuration: 3000
|
|
107
94
|
});
|
|
108
95
|
}
|
|
109
|
-
else if ((contribution === null || contribution === void 0 ? void 0 : contribution.group) && status !== SCGroupSubscriptionStatusType.SUBSCRIBED) {
|
|
110
|
-
enqueueSnackbar(React.createElement(FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
|
|
111
|
-
variant: 'warning',
|
|
112
|
-
autoHideDuration: 3000
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
96
|
else {
|
|
116
97
|
handleVote(reaction);
|
|
117
98
|
}
|