@selfcommunity/react-ui 0.7.9-alpha.7 → 0.7.9-alpha.71
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/AccountRecover/AccountRecover.js +6 -1
- package/lib/cjs/components/BottomNavigation/BottomNavigation.js +4 -3
- package/lib/cjs/components/CategoryHeader/Skeleton.js +3 -2
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +13 -10
- package/lib/cjs/components/Composer/Attributes/Attributes.js +3 -3
- package/lib/cjs/components/Composer/Composer.js +3 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
- package/lib/cjs/components/FeedObject/Contributors/Contributors.js +1 -1
- package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/cjs/components/FeedObject/FeedObject.js +27 -8
- package/lib/cjs/components/FeedObject/Poll/Poll.js +20 -20
- package/lib/cjs/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
- package/lib/cjs/components/Group/Group.d.ts +8 -0
- package/lib/cjs/components/Group/Group.js +17 -5
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
- package/lib/cjs/components/GroupForm/GroupForm.js +64 -13
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
- package/lib/cjs/components/GroupHeader/GroupHeader.js +53 -11
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +63 -9
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +31 -9
- package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +74 -0
- package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +221 -0
- package/lib/cjs/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
- package/lib/cjs/components/GroupInvitedWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupInvitedWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupInvitedWidget/constants.js +4 -0
- package/lib/cjs/components/GroupInvitedWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupInvitedWidget/index.js +8 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +8 -3
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +25 -4
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +151 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
- package/lib/cjs/components/Groups/Groups.d.ts +15 -8
- package/lib/cjs/components/Groups/Groups.js +86 -32
- package/lib/cjs/components/Groups/Skeleton.d.ts +4 -0
- package/lib/cjs/components/Groups/Skeleton.js +2 -2
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +7 -0
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/cjs/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +6 -2
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -4
- package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
- package/lib/cjs/components/Notification/Group/Group.js +78 -0
- package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
- package/lib/cjs/components/Notification/Group/index.js +5 -0
- package/lib/cjs/components/Notification/Notification.js +31 -1
- package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +12 -7
- package/lib/cjs/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +1 -1
- package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +45 -20
- package/lib/cjs/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +6 -0
- package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
- package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/cjs/components/User/User.d.ts +6 -1
- package/lib/cjs/components/User/User.js +5 -4
- package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.js +46 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +183 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/constants.js +4 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/index.js +8 -0
- package/lib/cjs/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
- package/lib/cjs/constants/PubSub.d.ts +28 -0
- package/lib/cjs/constants/PubSub.js +22 -0
- package/lib/cjs/index.d.ts +6 -2
- package/lib/cjs/index.js +15 -4
- package/lib/esm/components/AccountRecover/AccountRecover.js +6 -1
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +5 -4
- package/lib/esm/components/CategoryHeader/Skeleton.js +3 -2
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +13 -10
- package/lib/esm/components/Composer/Attributes/Attributes.js +3 -3
- package/lib/esm/components/Composer/Composer.js +3 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
- package/lib/esm/components/FeedObject/Contributors/Contributors.js +1 -1
- package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/esm/components/FeedObject/FeedObject.js +28 -9
- package/lib/esm/components/FeedObject/Poll/Poll.js +20 -20
- package/lib/esm/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
- package/lib/esm/components/Group/Group.d.ts +8 -0
- package/lib/esm/components/Group/Group.js +21 -9
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
- package/lib/esm/components/GroupForm/GroupForm.js +64 -13
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
- package/lib/esm/components/GroupHeader/GroupHeader.js +55 -13
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +63 -9
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +31 -9
- package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +74 -0
- package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +218 -0
- package/lib/esm/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
- package/lib/esm/components/GroupInvitedWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupInvitedWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupInvitedWidget/constants.js +1 -0
- package/lib/esm/components/GroupInvitedWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupInvitedWidget/index.js +4 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +9 -4
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +26 -5
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +148 -0
- package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
- package/lib/esm/components/Groups/Groups.d.ts +15 -8
- package/lib/esm/components/Groups/Groups.js +91 -37
- package/lib/esm/components/Groups/Skeleton.d.ts +4 -0
- package/lib/esm/components/Groups/Skeleton.js +2 -2
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +9 -2
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/esm/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +7 -3
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +13 -6
- package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
- package/lib/esm/components/Notification/Group/Group.js +75 -0
- package/lib/esm/components/Notification/Group/index.d.ts +3 -0
- package/lib/esm/components/Notification/Group/index.js +2 -0
- package/lib/esm/components/Notification/Notification.js +31 -1
- package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +13 -8
- package/lib/esm/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +1 -1
- package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +47 -22
- package/lib/esm/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +7 -1
- package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
- package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/esm/components/User/User.d.ts +6 -1
- package/lib/esm/components/User/User.js +5 -4
- package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.js +42 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +180 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/constants.js +1 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/index.js +4 -0
- package/lib/esm/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
- package/lib/esm/constants/PubSub.d.ts +28 -0
- package/lib/esm/constants/PubSub.js +19 -0
- package/lib/esm/index.d.ts +6 -2
- package/lib/esm/index.js +8 -4
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { Avatar, Box, Stack, Typography } from '@mui/material';
|
|
5
|
+
import { Link, SCRoutes, SCUserContext, useSCRouting } from '@selfcommunity/react-core';
|
|
6
|
+
import { SCGroupSubscriptionStatusType } from '@selfcommunity/types';
|
|
7
|
+
import { FormattedMessage } from 'react-intl';
|
|
8
|
+
import DateTimeAgo from '../../../shared/DateTimeAgo';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import { SCNotificationObjectTemplateType } from '../../../types';
|
|
11
|
+
import NotificationItem from '../../../shared/NotificationItem';
|
|
12
|
+
import { LoadingButton } from '@mui/lab';
|
|
13
|
+
import UserDeletedSnackBar from '../../../shared/UserDeletedSnackBar';
|
|
14
|
+
import UserAvatar from '../../../shared/UserAvatar';
|
|
15
|
+
import { PREFIX } from '../constants';
|
|
16
|
+
const classes = {
|
|
17
|
+
root: `${PREFIX}-group-root`,
|
|
18
|
+
avatar: `${PREFIX}-avatar`,
|
|
19
|
+
actions: `${PREFIX}-actions`,
|
|
20
|
+
acceptButton: `${PREFIX}-reply-button`,
|
|
21
|
+
activeAt: `${PREFIX}-active-at`,
|
|
22
|
+
username: `${PREFIX}-username`
|
|
23
|
+
};
|
|
24
|
+
const Root = styled(NotificationItem, {
|
|
25
|
+
name: PREFIX,
|
|
26
|
+
slot: 'GroupRoot'
|
|
27
|
+
})(() => ({}));
|
|
28
|
+
/**
|
|
29
|
+
* This component render the content of the notification of type group
|
|
30
|
+
* @constructor
|
|
31
|
+
* @param props
|
|
32
|
+
*/
|
|
33
|
+
export default function GroupNotification(props) {
|
|
34
|
+
// PROPS
|
|
35
|
+
const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = SCNotificationObjectTemplateType.DETAIL } = props, rest = __rest(props, ["notificationObject", "id", "className", "template"]);
|
|
36
|
+
// CONTEXT
|
|
37
|
+
const scRoutingContext = useSCRouting();
|
|
38
|
+
const scUserContext = useContext(SCUserContext);
|
|
39
|
+
const manager = scUserContext.managers.groups;
|
|
40
|
+
// STATE
|
|
41
|
+
const [status, setStatus] = useState(null);
|
|
42
|
+
const [openAlert, setOpenAlert] = useState(false);
|
|
43
|
+
// CONST
|
|
44
|
+
const isSnippetTemplate = template === SCNotificationObjectTemplateType.SNIPPET;
|
|
45
|
+
const isToastTemplate = template === SCNotificationObjectTemplateType.TOAST;
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setStatus(manager.subscriptionStatus(notificationObject.group));
|
|
48
|
+
}, [manager.subscriptionStatus, notificationObject.group]);
|
|
49
|
+
// RENDER
|
|
50
|
+
if (isSnippetTemplate || isToastTemplate) {
|
|
51
|
+
return (React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: React.createElement(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
52
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
53
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }),
|
|
54
|
+
React.createElement(UserAvatar, { hide: !notificationObject.user.community_badge, smaller: true },
|
|
55
|
+
React.createElement(Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }))), primary: React.createElement(Box, null,
|
|
56
|
+
React.createElement(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
57
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
58
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }), notificationObject.user.username),
|
|
59
|
+
' ',
|
|
60
|
+
React.createElement(FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
|
|
61
|
+
group: notificationObject.group.name,
|
|
62
|
+
link: (...chunks) => React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) }, chunks)
|
|
63
|
+
} })), footer: isToastTemplate && (React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
|
|
64
|
+
React.createElement(DateTimeAgo, { date: notificationObject.active_at }),
|
|
65
|
+
status && status !== SCGroupSubscriptionStatusType.SUBSCRIBED && (React.createElement(Typography, { color: "primary" },
|
|
66
|
+
React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) },
|
|
67
|
+
React.createElement(FormattedMessage, { id: "ui.notification.group.button.see", defaultMessage: "ui.notification.group.button.see" })))))) }, rest)));
|
|
68
|
+
}
|
|
69
|
+
return (React.createElement(React.Fragment, null,
|
|
70
|
+
React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, actions: React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
|
|
71
|
+
React.createElement(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }),
|
|
72
|
+
status && status !== SCGroupSubscriptionStatusType.SUBSCRIBED && (React.createElement(LoadingButton, { color: 'primary', variant: "outlined", size: "small", classes: { root: classes.acceptButton }, component: Link, loading: scUserContext.user ? status === null || manager.isLoading(notificationObject.group) : null, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) },
|
|
73
|
+
React.createElement(FormattedMessage, { id: "ui.notification.group.button.see", defaultMessage: "ui.notification.group.button.see" })))) }, rest)),
|
|
74
|
+
openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
75
|
+
}
|
|
@@ -33,6 +33,7 @@ import { SCNotificationTypologyType } from '@selfcommunity/types';
|
|
|
33
33
|
import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
|
|
34
34
|
import UserAvatar from '../../shared/UserAvatar';
|
|
35
35
|
import { PREFIX } from './constants';
|
|
36
|
+
import GroupNotification from './Group';
|
|
36
37
|
const messages = defineMessages({
|
|
37
38
|
receivePrivateMessage: {
|
|
38
39
|
id: 'ui.notification.receivePrivateMessage',
|
|
@@ -149,7 +150,7 @@ export default function UserNotification(inProps) {
|
|
|
149
150
|
}
|
|
150
151
|
/**
|
|
151
152
|
* Handles vote
|
|
152
|
-
* @param
|
|
153
|
+
* @param index
|
|
153
154
|
*/
|
|
154
155
|
const handleVote = (index) => {
|
|
155
156
|
return (contribution) => {
|
|
@@ -194,6 +195,29 @@ export default function UserNotification(inProps) {
|
|
|
194
195
|
b: (...chunks) => React.createElement("strong", null, chunks)
|
|
195
196
|
})) }));
|
|
196
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Group notifications header
|
|
200
|
+
*/
|
|
201
|
+
if (notificationObject.aggregated &&
|
|
202
|
+
(notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
|
|
203
|
+
notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
|
|
204
|
+
notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
|
|
205
|
+
notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP)) {
|
|
206
|
+
let groupNotification = notificationObject.aggregated[0];
|
|
207
|
+
return (React.createElement(CardHeader, { className: classes.header, avatar: React.createElement(Link, Object.assign({}, (!groupNotification.user.deleted && {
|
|
208
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, groupNotification.user)
|
|
209
|
+
}), { onClick: groupNotification.user.deleted ? () => setOpenAlert(true) : null }),
|
|
210
|
+
React.createElement(UserAvatar, { hide: !groupNotification.user.community_badge, smaller: true },
|
|
211
|
+
React.createElement(Avatar, { className: classes.avatar, alt: groupNotification.user.username, variant: "circular", src: groupNotification.user.avatar }))), titleTypographyProps: { className: classes.title, variant: 'subtitle1' }, title: React.createElement(React.Fragment, null,
|
|
212
|
+
React.createElement(Link, Object.assign({}, (!groupNotification.user.deleted && {
|
|
213
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, groupNotification.user)
|
|
214
|
+
}), { onClick: groupNotification.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }), groupNotification.user.username),
|
|
215
|
+
' ',
|
|
216
|
+
React.createElement(FormattedMessage, { id: `ui.notification.${notificationObject.aggregated[0].type}`, defaultMessage: `ui.notification.${notificationObject.aggregated[0].type}`, values: {
|
|
217
|
+
group: groupNotification.group.name,
|
|
218
|
+
link: (...chunks) => React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, groupNotification.group) }, chunks)
|
|
219
|
+
} })) }));
|
|
220
|
+
}
|
|
197
221
|
/**
|
|
198
222
|
* Comment, NestedComment, Follow Contribution header
|
|
199
223
|
*/
|
|
@@ -276,6 +300,12 @@ export default function UserNotification(inProps) {
|
|
|
276
300
|
else if (n.type === SCNotificationTypologyType.CONTRIBUTION) {
|
|
277
301
|
return React.createElement(ContributionNotification, { notificationObject: n, key: i, onVote: handleVote(i) });
|
|
278
302
|
}
|
|
303
|
+
else if (n.type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
|
|
304
|
+
n.type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
|
|
305
|
+
n.type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
|
|
306
|
+
n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
|
|
307
|
+
return React.createElement(GroupNotification, { notificationObject: n, key: i });
|
|
308
|
+
}
|
|
279
309
|
return null;
|
|
280
310
|
}
|
|
281
311
|
/**
|
|
@@ -39,6 +39,7 @@ const Root = styled(NotificationItem, {
|
|
|
39
39
|
* @param props
|
|
40
40
|
*/
|
|
41
41
|
export default function PrivateMessageNotification(props) {
|
|
42
|
+
var _a, _b, _c, _d, _e;
|
|
42
43
|
// PROPS
|
|
43
44
|
const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = SCNotificationObjectTemplateType.DETAIL } = props, rest = __rest(props, ["notificationObject", "id", "className", "template"]);
|
|
44
45
|
// CONTEXT
|
|
@@ -89,7 +90,9 @@ export default function PrivateMessageNotification(props) {
|
|
|
89
90
|
React.createElement(FormattedMessage, { id: 'ui.userToastNotifications.privateMessage.sentMessage', defaultMessage: 'ui.userToastNotifications.privateMessage.sentMessage' }),
|
|
90
91
|
":",
|
|
91
92
|
React.createElement(Box, { className: classes.messageWrap },
|
|
92
|
-
React.createElement(Link, { to:
|
|
93
|
+
React.createElement(Link, { to: ((_a = notificationObject.message) === null || _a === void 0 ? void 0 : _a.group)
|
|
94
|
+
? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
|
|
95
|
+
: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.message },
|
|
93
96
|
React.createElement(Typography, { variant: "body2", dangerouslySetInnerHTML: { __html: notificationObject.message.message } }))))),
|
|
94
97
|
isSnippetTemplate && (React.createElement(Box, null,
|
|
95
98
|
React.createElement(Typography, { component: "div", color: "inherit" },
|
|
@@ -97,13 +100,17 @@ export default function PrivateMessageNotification(props) {
|
|
|
97
100
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.message.sender)
|
|
98
101
|
}), { onClick: notificationObject.message.sender.deleted ? () => setOpenAlert(true) : null, className: classes.username }), notificationObject.message.sender.username),
|
|
99
102
|
' ',
|
|
100
|
-
React.createElement(Link, { to:
|
|
103
|
+
React.createElement(Link, { to: ((_b = notificationObject.message) === null || _b === void 0 ? void 0 : _b.group)
|
|
104
|
+
? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
|
|
105
|
+
: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.messageLabel }, intl.formatMessage(messages.receivePrivateMessage, {
|
|
101
106
|
total: 1,
|
|
102
107
|
b: (...chunks) => React.createElement("strong", null, chunks)
|
|
103
108
|
})))))), footer: isToastTemplate && (React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
|
|
104
109
|
React.createElement(DateTimeAgo, { date: notificationObject.active_at }),
|
|
105
110
|
React.createElement(Typography, { color: "primary" },
|
|
106
|
-
React.createElement(Link, { to:
|
|
111
|
+
React.createElement(Link, { to: ((_c = notificationObject.message) === null || _c === void 0 ? void 0 : _c.group)
|
|
112
|
+
? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
|
|
113
|
+
: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender) }, scUserContext.user && follower ? (React.createElement(FormattedMessage, { id: "ui.userToastNotifications.replyMessage", defaultMessage: 'ui.userToastNotifications.replyMessage' })) : (React.createElement(FormattedMessage, { id: "ui.userToastNotifications.viewMessage", defaultMessage: 'ui.userToastNotifications.viewMessage' })))))) }, rest)));
|
|
107
114
|
}
|
|
108
115
|
return (React.createElement(React.Fragment, null,
|
|
109
116
|
React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, actions: React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
|
|
@@ -112,8 +119,12 @@ export default function PrivateMessageNotification(props) {
|
|
|
112
119
|
? null
|
|
113
120
|
: scUserContext.user
|
|
114
121
|
? follower === null || manager.isLoading(notificationObject.message.sender)
|
|
115
|
-
: null, to:
|
|
116
|
-
|
|
122
|
+
: null, to: ((_d = notificationObject.message) === null || _d === void 0 ? void 0 : _d.group)
|
|
123
|
+
? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
|
|
124
|
+
: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender) }, scUserContext.user && follower ? (React.createElement(FormattedMessage, { id: "ui.notification.privateMessage.btnReplyLabel", defaultMessage: "ui.notification.privateMessage.btnReplyLabel" })) : (React.createElement(FormattedMessage, { id: "ui.notification.privateMessage.btnViewLabel", defaultMessage: "ui.notification.privateMessage.btnViewLabel" })))), primary: React.createElement(Box, { className: classes.messageWrap },
|
|
125
|
+
React.createElement(Link, { to: ((_e = notificationObject.message) === null || _e === void 0 ? void 0 : _e.group)
|
|
126
|
+
? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
|
|
127
|
+
: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.message },
|
|
117
128
|
React.createElement(Typography, { variant: "body2", dangerouslySetInnerHTML: { __html: notificationObject.message.message } }))) }, rest)),
|
|
118
129
|
openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
119
130
|
}
|
|
@@ -5,7 +5,7 @@ import { Grid, useMediaQuery, useTheme } from '@mui/material';
|
|
|
5
5
|
import { useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { useThemeProps } from '@mui/system';
|
|
8
|
-
import { SCFeatureName, SCPrivateMessageStatusType } from '@selfcommunity/types';
|
|
8
|
+
import { SCFeatureName, SCPrivateMessageStatusType, SCPrivateMessageType } from '@selfcommunity/types';
|
|
9
9
|
import PrivateMessageThread from '../PrivateMessageThread';
|
|
10
10
|
import PrivateMessageSnippets from '../PrivateMessageSnippets';
|
|
11
11
|
import { PREFIX } from './constants';
|
|
@@ -65,6 +65,7 @@ export default function PrivateMessageComponent(inProps) {
|
|
|
65
65
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
66
66
|
const [layout, setLayout] = useState('default');
|
|
67
67
|
const [obj, setObj] = useState(id !== null && id !== void 0 ? id : null);
|
|
68
|
+
const [type, setType] = useState(null);
|
|
68
69
|
const isNew = obj && obj === SCPrivateMessageStatusType.NEW;
|
|
69
70
|
const [openNewMessage, setOpenNewMessage] = useState(isNew !== null && isNew !== void 0 ? isNew : false);
|
|
70
71
|
const mobileSnippetsView = (layout === 'default' && !obj) || (layout === 'mobile' && !obj);
|
|
@@ -86,10 +87,12 @@ export default function PrivateMessageComponent(inProps) {
|
|
|
86
87
|
/**
|
|
87
88
|
* Handles thread opening on click
|
|
88
89
|
* @param item
|
|
90
|
+
* @param type
|
|
89
91
|
*/
|
|
90
|
-
const handleThreadOpening = (item) => {
|
|
91
|
-
onItemClick && onItemClick(messageReceiver(item, authUserId));
|
|
92
|
-
|
|
92
|
+
const handleThreadOpening = (item, type) => {
|
|
93
|
+
onItemClick && onItemClick(item.group ? item.group.id : messageReceiver(item, authUserId), type);
|
|
94
|
+
setType(type);
|
|
95
|
+
setObj(item.group ? item : messageReceiver(item, authUserId));
|
|
93
96
|
setOpenNewMessage(false);
|
|
94
97
|
};
|
|
95
98
|
/**
|
|
@@ -105,7 +108,8 @@ export default function PrivateMessageComponent(inProps) {
|
|
|
105
108
|
const handleOpenNewMessage = () => {
|
|
106
109
|
setOpenNewMessage(!openNewMessage);
|
|
107
110
|
setObj(SCPrivateMessageStatusType.NEW);
|
|
108
|
-
|
|
111
|
+
setType(SCPrivateMessageType.NEW);
|
|
112
|
+
onItemClick && onItemClick(SCPrivateMessageStatusType.NEW, SCPrivateMessageType.NEW);
|
|
109
113
|
};
|
|
110
114
|
/**
|
|
111
115
|
* Handles new messages open from user profile page or notifications section
|
|
@@ -121,13 +125,14 @@ export default function PrivateMessageComponent(inProps) {
|
|
|
121
125
|
id && setLayout('mobile');
|
|
122
126
|
setOpenNewMessage(false);
|
|
123
127
|
setObj(null);
|
|
128
|
+
setType(null);
|
|
124
129
|
onThreadBack && onThreadBack();
|
|
125
130
|
};
|
|
126
131
|
/**
|
|
127
132
|
* Handles state update when a new message is sent
|
|
128
133
|
*/
|
|
129
134
|
const handleOnNewMessageSent = (msg, isOne) => {
|
|
130
|
-
onItemClick && onItemClick(isOne ? messageReceiver(msg, authUserId) : '');
|
|
135
|
+
onItemClick && onItemClick(isOne ? messageReceiver(msg, authUserId) : '', msg.group ? SCPrivateMessageType.GROUP : SCPrivateMessageType.USER);
|
|
131
136
|
setObj(isOne ? messageReceiver(msg, authUserId) : null);
|
|
132
137
|
setOpenNewMessage(false);
|
|
133
138
|
};
|
|
@@ -147,14 +152,14 @@ export default function PrivateMessageComponent(inProps) {
|
|
|
147
152
|
onSnippetClick: handleThreadOpening,
|
|
148
153
|
onNewMessageClick: handleOpenNewMessage,
|
|
149
154
|
onDeleteConfirm: handleDeleteThread
|
|
150
|
-
},
|
|
155
|
+
}, threadObj: obj, clearSearch: clear, elevation: 0 })));
|
|
151
156
|
}
|
|
152
157
|
/**
|
|
153
158
|
* Renders thread section
|
|
154
159
|
*/
|
|
155
160
|
function renderThread() {
|
|
156
161
|
return (React.createElement(Grid, { item: true, xs: 12, md: 7, className: classNames(classes.threadBox, { [classes.hide]: isMobile && mobileSnippetsView }) },
|
|
157
|
-
React.createElement(PrivateMessageThread, {
|
|
162
|
+
React.createElement(PrivateMessageThread, { threadObj: obj, type: type, openNewMessage: openNewMessage, onNewMessageClose: handleMessageBack, onNewMessageSent: handleOnNewMessageSent, onSingleMessageOpen: handleSingleMessage, elevation: 0 })));
|
|
158
163
|
}
|
|
159
164
|
/**
|
|
160
165
|
* Renders the component (if not hidden by autoHide prop)
|
package/lib/esm/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js
CHANGED
|
@@ -114,7 +114,7 @@ export default function PrivateMessageSettingsIconButton(inProps) {
|
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
116
|
return [
|
|
117
|
-
user && (React.createElement(MenuItem, { className: classes.item, component: Link, to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, user), key: "profile" },
|
|
117
|
+
user && (React.createElement(MenuItem, { className: classes.item, component: Link, to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, user), key: "profile", onClick: handleCloseDialog },
|
|
118
118
|
React.createElement(ListItemIcon, null,
|
|
119
119
|
React.createElement(Icon, { fontSize: "small" }, "people_alt")),
|
|
120
120
|
React.createElement(FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.profile", defaultMessage: "ui.privateMessageSettingsIconButton.item.profile" }))),
|
|
@@ -72,10 +72,12 @@ export default function PrivateMessageSnippetItem(inProps) {
|
|
|
72
72
|
// STATE
|
|
73
73
|
const hasBadge = () => {
|
|
74
74
|
var _a;
|
|
75
|
-
if (
|
|
76
|
-
|
|
75
|
+
if (message.receiver) {
|
|
76
|
+
if ((message === null || message === void 0 ? void 0 : message.receiver.id) !== ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
77
|
+
return message === null || message === void 0 ? void 0 : message.receiver.community_badge;
|
|
78
|
+
}
|
|
79
|
+
return message === null || message === void 0 ? void 0 : message.sender.community_badge;
|
|
77
80
|
}
|
|
78
|
-
return message === null || message === void 0 ? void 0 : message.sender.community_badge;
|
|
79
81
|
};
|
|
80
82
|
if (!message) {
|
|
81
83
|
return React.createElement(PrivateMessageSnippetItemSkeleton, { elevation: 0 });
|
|
@@ -86,10 +88,13 @@ export default function PrivateMessageSnippetItem(inProps) {
|
|
|
86
88
|
return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { secondaryAction: secondaryAction, disablePadding: true }),
|
|
87
89
|
React.createElement(ListItemButton, { onClick: onItemClick, classes: { root: classNames({ [classes.unread]: message.thread_status === SCPrivateMessageStatusType.NEW }) } },
|
|
88
90
|
React.createElement(ListItemAvatar, null,
|
|
89
|
-
React.createElement(UserAvatar, { hide: !hasBadge() },
|
|
90
|
-
React.createElement(Avatar, { alt: ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) === message.receiver.username ? message.sender.username : message.receiver.username, src: ((_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.username) === message.receiver.username ? message.sender.avatar : message.receiver.avatar }))),
|
|
91
|
+
React.createElement(UserAvatar, { hide: !hasBadge() }, message.group ? (React.createElement(Avatar, { alt: message.group.name, src: message.group.image_big })) : (React.createElement(Avatar, { alt: ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) === message.receiver.username ? message.sender.username : message.receiver.username, src: ((_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.username) === message.receiver.username ? message.sender.avatar : message.receiver.avatar })))),
|
|
91
92
|
React.createElement(ListItemText, { primary: React.createElement(React.Fragment, null,
|
|
92
|
-
React.createElement(Typography, { component: "span", className: classes.username },
|
|
93
|
+
React.createElement(Typography, { component: "span", className: classes.username }, message.group
|
|
94
|
+
? message.group.name
|
|
95
|
+
: ((_c = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _c === void 0 ? void 0 : _c.username) === message.receiver.username
|
|
96
|
+
? message.sender.username
|
|
97
|
+
: message.receiver.username),
|
|
93
98
|
hasBadge() && preferences && (React.createElement(Chip, { component: "span", className: classes.badgeLabel, size: "small", label: preferences[SCPreferences.STAFF_STAFF_BADGE_LABEL] })),
|
|
94
99
|
React.createElement(Typography, { color: "secondary", className: classes.time, component: "span" }, `${intl.formatDate(message.last_message_at, {
|
|
95
100
|
day: '2-digit',
|
|
@@ -20,7 +20,7 @@ export interface PrivateMessageSnippetsProps extends CardProps {
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
snippetActions?: {
|
|
23
|
-
onSnippetClick?: (msg: any) => void;
|
|
23
|
+
onSnippetClick?: (msg: any, type: any) => void;
|
|
24
24
|
onNewMessageClick?: () => void;
|
|
25
25
|
onDeleteConfirm?: (msg: any) => void;
|
|
26
26
|
};
|
|
@@ -29,10 +29,10 @@ export interface PrivateMessageSnippetsProps extends CardProps {
|
|
|
29
29
|
*/
|
|
30
30
|
[p: string]: any;
|
|
31
31
|
/**
|
|
32
|
-
* thread user object
|
|
32
|
+
* thread user/ group object
|
|
33
33
|
* @default null
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
threadObj?: any;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* > API documentation for the Community-JS PrivateMessageSnippets component. Learn about the available props and the CSS API.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { Button, Card, CardContent, Icon, IconButton, List, TextField, useTheme } from '@mui/material';
|
|
5
5
|
import PubSub from 'pubsub-js';
|
|
6
|
-
import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType } from '@selfcommunity/types';
|
|
6
|
+
import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType, SCPrivateMessageType } from '@selfcommunity/types';
|
|
7
7
|
import PrivateMessageSnippetsSkeleton from './Skeleton';
|
|
8
8
|
import PrivateMessageSnippetItem from '../PrivateMessageSnippetItem';
|
|
9
9
|
import classNames from 'classnames';
|
|
@@ -69,25 +69,30 @@ export default function PrivateMessageSnippets(inProps) {
|
|
|
69
69
|
props: inProps,
|
|
70
70
|
name: PREFIX
|
|
71
71
|
});
|
|
72
|
-
const { className = null,
|
|
72
|
+
const { className = null, threadObj = null, snippetActions, clearSearch } = props, rest = __rest(props, ["className", "threadObj", "snippetActions", "clearSearch"]);
|
|
73
73
|
// STATE
|
|
74
74
|
const theme = useTheme();
|
|
75
75
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
76
76
|
const { data, updateSnippets } = useSCFetchPrivateMessageSnippets({ cacheStrategy: CacheStrategies.CACHE_FIRST });
|
|
77
77
|
const [search, setSearch] = useState('');
|
|
78
|
-
const isObj = typeof
|
|
78
|
+
const isObj = typeof threadObj === 'object';
|
|
79
79
|
const scUserContext = useContext(SCUserContext);
|
|
80
80
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
81
|
+
const [type, setType] = useState(null);
|
|
81
82
|
// INTL
|
|
82
83
|
const intl = useIntl();
|
|
83
84
|
// REFS
|
|
84
85
|
const refreshSubscription = useRef(null);
|
|
85
86
|
// CONST
|
|
86
87
|
const filteredSnippets = data.snippets.filter((el) => {
|
|
88
|
+
var _a;
|
|
87
89
|
if (search === '') {
|
|
88
90
|
return el;
|
|
89
91
|
}
|
|
90
|
-
else if (el.
|
|
92
|
+
else if (el.group) {
|
|
93
|
+
return el.group.slug.includes(search.toLowerCase());
|
|
94
|
+
}
|
|
95
|
+
else if (((_a = el === null || el === void 0 ? void 0 : el.receiver) === null || _a === void 0 ? void 0 : _a.id) === authUserId) {
|
|
91
96
|
return el.sender.username.includes(search.toLowerCase());
|
|
92
97
|
}
|
|
93
98
|
return el.receiver.username.includes(search.toLowerCase());
|
|
@@ -99,6 +104,18 @@ export default function PrivateMessageSnippets(inProps) {
|
|
|
99
104
|
}
|
|
100
105
|
return ((_b = item === null || item === void 0 ? void 0 : item.receiver) === null || _b === void 0 ? void 0 : _b.id) !== loggedUserId ? (_c = item === null || item === void 0 ? void 0 : item.receiver) === null || _c === void 0 ? void 0 : _c.id : (_d = item === null || item === void 0 ? void 0 : item.sender) === null || _d === void 0 ? void 0 : _d.id;
|
|
101
106
|
};
|
|
107
|
+
const isSelected = useMemo(() => {
|
|
108
|
+
return (message) => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
if (threadObj && type === SCPrivateMessageType.GROUP) {
|
|
111
|
+
return ((_a = message === null || message === void 0 ? void 0 : message.group) === null || _a === void 0 ? void 0 : _a.id) === (isObj ? (_b = threadObj === null || threadObj === void 0 ? void 0 : threadObj.group) === null || _b === void 0 ? void 0 : _b.id : threadObj);
|
|
112
|
+
}
|
|
113
|
+
else if (threadObj && type === SCPrivateMessageType.USER) {
|
|
114
|
+
return messageReceiver(message, authUserId) === (isObj ? messageReceiver(threadObj, authUserId) : threadObj);
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
}, [threadObj, authUserId, type]);
|
|
102
119
|
//HANDLERS
|
|
103
120
|
const handleChange = (event) => {
|
|
104
121
|
setSearch(event.target.value);
|
|
@@ -114,7 +131,9 @@ export default function PrivateMessageSnippets(inProps) {
|
|
|
114
131
|
snippetActions && snippetActions.onDeleteConfirm(msg);
|
|
115
132
|
};
|
|
116
133
|
function handleOpenThread(msg) {
|
|
117
|
-
|
|
134
|
+
const _type = msg.group !== null ? SCPrivateMessageType.GROUP : SCPrivateMessageType.USER;
|
|
135
|
+
setType(_type);
|
|
136
|
+
snippetActions && snippetActions.onSnippetClick(msg, _type);
|
|
118
137
|
handleClear();
|
|
119
138
|
updateSnippetsParams(msg.id, 'seen');
|
|
120
139
|
}
|
|
@@ -219,6 +238,5 @@ export default function PrivateMessageSnippets(inProps) {
|
|
|
219
238
|
} }),
|
|
220
239
|
React.createElement(List, null, filteredSnippets.map((message) => (React.createElement(PrivateMessageSnippetItem, { message: message, key: message.id, onItemClick: () => handleOpenThread(message), secondaryAction: React.createElement(React.Fragment, null,
|
|
221
240
|
message.thread_status === SCPrivateMessageStatusType.NEW && (React.createElement(Icon, { fontSize: "small", color: "secondary" }, "fiber_manual_record")),
|
|
222
|
-
!isMobile && (React.createElement(PrivateMessageSettingsIconButton, { threadToDelete: messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true) }))), selected:
|
|
223
|
-
messageReceiver(message, authUserId) === (isObj ? messageReceiver(userObj, authUserId) : userObj) })))))))));
|
|
241
|
+
!isMobile && (React.createElement(PrivateMessageSettingsIconButton, { threadToDelete: messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true) }))), selected: isSelected(message) })))))))));
|
|
224
242
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { SCPrivateMessageType } from '@selfcommunity/types';
|
|
1
2
|
import { CardProps } from '@mui/material';
|
|
2
3
|
export interface PrivateMessageThreadProps extends CardProps {
|
|
3
4
|
/**
|
|
4
5
|
* Thread object or thread id
|
|
5
6
|
* default null
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
threadObj?: any;
|
|
8
9
|
/**
|
|
9
10
|
* Overrides or extends the styles applied to the component.
|
|
10
11
|
* @default null
|
|
@@ -30,6 +31,10 @@ export interface PrivateMessageThreadProps extends CardProps {
|
|
|
30
31
|
* @default null
|
|
31
32
|
*/
|
|
32
33
|
onSingleMessageOpen?: (open: boolean) => void;
|
|
34
|
+
/**
|
|
35
|
+
* The Thread type
|
|
36
|
+
*/
|
|
37
|
+
type?: SCPrivateMessageType;
|
|
33
38
|
/**
|
|
34
39
|
* Any other properties
|
|
35
40
|
*/
|