Skip to content

Commit f86682e

Browse files
authored
Merge pull request #2077 from appirio-tech/revert-2071-mil-53-issue-2039
Revert "messages by same user with time gap of 10min + show separately with a…"
2 parents 8b82704 + 69139df commit f86682e

File tree

4 files changed

+22
-48
lines changed

4 files changed

+22
-48
lines changed

src/components/ActionCard/CommentMobile.jsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,20 @@ import PropTypes from 'prop-types'
88
import _ from 'lodash'
99
import moment from 'moment'
1010
import { Link } from 'react-router-dom'
11-
import cn from 'classnames'
12-
1311
import UserWithName from '../User/UserWithName'
1412
import { POST_TIME_FORMAT } from '../../config/constants.js'
1513

1614
import './CommentMobile.scss'
1715

18-
const CommentMobile = ({ messageId, author, date, children, noInfo }) => {
16+
const CommentMobile = ({ messageId, author, date, children }) => {
1917
const messageLink = window.location.pathname.substr(0, window.location.pathname.indexOf('#')) + `#comment-${messageId}`
2018

2119
return (
22-
<div styleName={cn('comment', {'is-bundled' : noInfo})} id={`comment-${messageId}`}>
23-
{
24-
!noInfo &&
25-
<div styleName="header">
26-
<UserWithName {..._.pick(author, 'firstName', 'lastName', 'photoURL')} size="40" />
27-
<Link styleName="date" to={messageLink}>{moment(date).format(POST_TIME_FORMAT)}</Link>
28-
</div>
29-
}
20+
<div styleName="comment" id={`comment-${messageId}`}>
21+
<div styleName="header">
22+
<UserWithName {..._.pick(author, 'firstName', 'lastName', 'photoURL')} size="40" />
23+
<Link styleName="date" to={messageLink}>{moment(date).format(POST_TIME_FORMAT)}</Link>
24+
</div>
3025
<div styleName="text" className="draftjs-post">{children}</div>
3126
</div>
3227
)
@@ -36,8 +31,7 @@ CommentMobile.propTypes = {
3631
messageId: PropTypes.string.isRequired,
3732
author: PropTypes.any.isRequired,
3833
date: PropTypes.any.isRequired,
39-
children: PropTypes.node.isRequired,
40-
noInfo: PropTypes.bool
34+
children: PropTypes.node.isRequired
4135
}
4236

4337
export default CommentMobile

src/components/ActionCard/CommentMobile.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@
55
border-radius: 4px;
66
margin-top: 3 * $base-unit;
77
padding: 2 * $base-unit 2 * $base-unit 3 * $base-unit 2 * $base-unit;
8-
9-
&.is-bundled {
10-
margin-top: 0;
11-
padding-top: 0;
12-
padding-bottom: 0;
13-
}
14-
15-
16-
&:not(.is-bundled) + .comment.is-bundled {
17-
margin-top: -15px;
18-
}
198
}
209

2110
.header {

src/components/Feed/FeedComments.jsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import cn from 'classnames'
77
import {markdownToHTML} from '../../helpers/markdownToState'
88
import MediaQuery from 'react-responsive'
99
import CommentMobile from '../ActionCard/CommentMobile'
10-
import { SCREEN_BREAKPOINT_MD, POSTS_BUNDLE_TIME_DIFF } from '../../config/constants'
10+
import { SCREEN_BREAKPOINT_MD } from '../../config/constants'
1111

1212
import './FeedComments.scss'
1313

@@ -61,7 +61,6 @@ class FeedComments extends React.Component {
6161
}
6262

6363
const desktopBlocks = []
64-
const mobileBlocks = []
6564

6665
if (hasMoreComments) {
6766
desktopBlocks.push(
@@ -73,12 +72,10 @@ class FeedComments extends React.Component {
7372
)
7473
}
7574

76-
comments && comments.forEach((item, idx) => {
75+
comments && comments.forEach((item, idx) => {
7776
const createdAt = moment(item.createdAt)
7877
const prevComment = comments[idx - 1]
79-
const timeDiffPrevComment = prevComment && moment(item.createdAt).diff(prevComment.createdAt)
80-
const isSameAuthor = prevComment && prevComment.author.userId === item.author.userId &&
81-
timeDiffPrevComment && timeDiffPrevComment <= POSTS_BUNDLE_TIME_DIFF
78+
const isSameAuthor = prevComment && prevComment.author.userId === item.author.userId
8279
const isSameDay = prevComment && moment(prevComment.createdAt).isSame(createdAt, 'day')
8380
const isFirstUnread = prevComment && !prevComment.unread && item.unread
8481

@@ -103,7 +100,7 @@ class FeedComments extends React.Component {
103100
key={idx}
104101
message={item}
105102
author={item.author}
106-
date={item.createdAt}
103+
date={item.date}
107104
edited={item.edited}
108105
active={item.unread}
109106
self={item.author && item.author.userId === currentUser.userId}
@@ -118,18 +115,6 @@ class FeedComments extends React.Component {
118115
<div dangerouslySetInnerHTML={{__html: markdownToHTML(item.content)}} />
119116
</Comment>
120117
)
121-
122-
mobileBlocks.push(
123-
<CommentMobile
124-
key={idx}
125-
messageId={item.id.toString()}
126-
author={item.author}
127-
date={item.createdAt}
128-
noInfo={isSameAuthor}
129-
>
130-
<div dangerouslySetInnerHTML={{__html: markdownToHTML(item.content)}} />
131-
</CommentMobile>
132-
)
133118
})
134119

135120
return (
@@ -164,7 +149,16 @@ class FeedComments extends React.Component {
164149
</a>
165150
</div>
166151
}
167-
{mobileBlocks}
152+
{comments.map((item, idx) => (
153+
<CommentMobile
154+
key={idx}
155+
messageId={item.id.toString()}
156+
author={item.author}
157+
date={item.date}
158+
>
159+
<div dangerouslySetInnerHTML={{__html: markdownToHTML(item.content)}} />
160+
</CommentMobile>
161+
))}
168162
</div>
169163
))}
170164
</MediaQuery>

src/config/constants.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,4 @@ export const NOTIFICATION_SETTINGS_PERIODS = [
537537
]
538538

539539
// date time formats
540-
export const POST_TIME_FORMAT = 'h:mm a'
541-
542-
// max time difference between consecutive posts to bundle posts by same user
543-
export const POSTS_BUNDLE_TIME_DIFF = 1000 * 60 * 10 // 10 min difference
540+
export const POST_TIME_FORMAT = 'h:mm a'

0 commit comments

Comments
 (0)