Skip to content

Commit 36791e3

Browse files
authored
Merge pull request #2659 from appirio-tech/issue-1985-notifications-reader
Issue #1985 - notifications reader
2 parents 0ccaa47 + 0a20316 commit 36791e3

File tree

20 files changed

+626
-433
lines changed

20 files changed

+626
-433
lines changed

src/components/ActionCard/Comment.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import { Link } from 'react-router-dom'
77
import CommentEditToggle from './CommentEditToggle'
88
import _ from 'lodash'
99
import moment from 'moment'
10-
import { POST_TIME_FORMAT } from '../../config/constants.js'
10+
import NotificationsReader from '../../components/NotificationsReader'
11+
import {
12+
POST_TIME_FORMAT,
13+
EVENT_TYPE,
14+
} from '../../config/constants.js'
1115

1216
import './Comment.scss'
1317

@@ -88,6 +92,14 @@ class Comment extends React.Component {
8892

8993
return (
9094
<div styleName={cn('container', { self, 'is-deleting': isDeleting })} id={messageAnchor}>
95+
<NotificationsReader
96+
id={messageAnchor}
97+
criteria={[
98+
{ eventType: EVENT_TYPE.POST.CREATED, contents: { postId: message.id } },
99+
{ eventType: EVENT_TYPE.POST.UPDATED, contents: { postId: message.id } },
100+
{ eventType: EVENT_TYPE.POST.MENTION, contents: { postId: message.id } },
101+
]}
102+
/>
91103
<div styleName="avatar">
92104
{!noInfo && author && <UserTooltip usr={author} id={`${messageAnchor}-${author.userId}`} previewAvatar size={40} />}
93105
</div>

src/components/Feed/Feed.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import PropTypes from 'prop-types'
55
import FeedComments from './FeedComments'
66
import CommentEditToggle from '../ActionCard/CommentEditToggle'
77
import RichTextArea from '../RichTextArea/RichTextArea'
8+
import NotificationsReader from '../../components/NotificationsReader'
9+
10+
import { EVENT_TYPE } from '../../config/constants'
811

912
import XMarkIcon from '../../assets/icons/x-mark.svg'
1013
import FullscreenIcon from '../../assets/icons/ui-fullscreen.svg'
@@ -99,6 +102,10 @@ class Feed extends React.Component {
99102

100103
topicHeader = (
101104
<header styleName="feed-header" ref="header">
105+
<NotificationsReader
106+
id={`topic-${id}`}
107+
criteria={{ eventType: EVENT_TYPE.TOPIC.CREATED, contents: { topicId: id } }}
108+
/>
102109
{editTopicMode ? (
103110
<div styleName="header-edit">
104111
<RichTextArea
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
/**
22
* Feed with support of scrolling
33
*/
4+
import React from 'react'
45
import { ScrollElement } from 'react-scroll'
56
import Feed from './Feed'
67

7-
const ScrollableFeed = ScrollElement(Feed) // eslint-disable-line new-cap
8+
// we need this workaround because `ScrollElement` accepts `id` as a String
9+
// while `Feed` accepts `id` as a Number
10+
// so parent component passes `id` as a String for `ScrollElement`
11+
// and `topicId` as a Number, and here we rename `topicId` back to `id` for `Feed`
12+
const FeedWithId = ({ topicId, ...props }) => (
13+
<Feed {...{ ...props, id: topicId }} />
14+
)
15+
16+
const ScrollableFeed = ScrollElement(FeedWithId) // eslint-disable-line new-cap
817

918
export default ScrollableFeed

0 commit comments

Comments
 (0)