Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Feed/FeedComments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class FeedComments extends React.Component {
allMembers={allMembers}
projectMembers={projectMembers}
noInfo={item.noInfo}
canDelete={idx !== 0}
canDelete={idx !== comments.length - 1} // cannot delete the first post which is now shown as a last one
commentAnchorPrefix={commentAnchorPrefix}
>
<div dangerouslySetInnerHTML={{__html: markdownToHTML(itemContent)}} />
Expand Down
41 changes: 26 additions & 15 deletions src/projects/detail/containers/FeedContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ class FeedView extends React.Component {
}

onShowAllComments(feedId) {
const { feeds } = this.props
const feed = _.find(feeds, feed => feed.id === feedId)
const { feeds } = this.state
const feed = _.find(feeds, { id: feedId })
const stateFeedIdx = _.findIndex(this.state.feeds, (f) => f.id === feedId)
// in case we have already have all comments for that feed from the server,
// just change the state to show all comments for that FeedId.
Expand All @@ -271,7 +271,7 @@ class FeedView extends React.Component {
showAll: { $push: [feedId] },
feeds: { $splice: [[stateFeedIdx, 1, updatedFeed ]] }
}))
this.props.loadFeedComments(feedId, PROJECT_FEED_TYPE_PRIMARY, commentIdsToRetrieve)
this.props.loadFeedComments(feedId, feed.tag, commentIdsToRetrieve)
} else {
this.setState(update(this.state, {
showAll: { $push: [feedId] },
Expand All @@ -281,13 +281,14 @@ class FeedView extends React.Component {
}

onAddNewComment(feedId, content) {
const { currentUser } = this.props
const { currentUser, feeds } = this.props
const feed = _.find(feeds, { id: feedId })
const newComment = {
date: new Date(),
userId: parseInt(currentUser.id),
content
}
this.props.addFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, newComment)
this.props.addFeedComment(feedId, feed.tag, newComment)
}

onSaveMessageChange(feedId, messageId, content, editMode) {
Expand All @@ -309,28 +310,34 @@ class FeedView extends React.Component {

onSaveMessage(feedId, message, content) {
const newMessage = {...message}
const { feeds } = this.state
const feed = _.find(feeds, { id: feedId })
newMessage.content = content
this.props.saveFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, newMessage)
this.props.saveFeedComment(feedId, feed.tag, newMessage)
}

onDeleteMessage(feedId, postId) {
this.props.deleteFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, postId)
const { feeds } = this.state
const feed = _.find(feeds, { id: feedId })
this.props.deleteFeedComment(feedId, feed.tag, postId)
}

onEditMessage(feedId, postId) {
const thread = _.find(this.state.feeds, t => feedId === t.id)
const comment = _.find(thread.comments, message => message.id === postId)
const { feeds } = this.state
const feed = _.find(feeds, { id: feedId })
const comment = _.find(feed.comments, message => message.id === postId)
if (!comment.rawContent) {
this.props.getFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, postId)
this.props.getFeedComment(feedId, feed.tag, postId)
}
this.onSaveMessageChange(feedId, postId, null, true)
}

onEditTopic(feedId) {
const thread = _.find(this.state.feeds, t => feedId === t.id)
const comment = thread.topicMessage
const { feeds } = this.state
const feed = _.find(feeds, { id: feedId })
const comment = feed.topicMessage
if (!comment.rawContent) {
this.props.getFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, comment.id)
this.props.getFeedComment(feedId, feed.tag, comment.id)
}
this.onTopicChange(feedId, comment.id, null, null, true)
}
Expand All @@ -350,11 +357,15 @@ class FeedView extends React.Component {
}

onSaveTopic(feedId, postId, title, content) {
this.props.saveProjectTopic(feedId, PROJECT_FEED_TYPE_PRIMARY, {postId, title, content})
const { feeds } = this.state
const feed = _.find(feeds, { id: feedId })
this.props.saveProjectTopic(feedId, feed.tag, {postId, title, content})
}

onDeleteTopic(feedId) {
this.props.deleteProjectTopic(feedId, PROJECT_FEED_TYPE_PRIMARY)
const { feeds } = this.state
const feed = _.find(feeds, { id: feedId })
this.props.deleteProjectTopic(feedId, feed.tag)
}

onRefreshFeeds() {
Expand Down
8 changes: 2 additions & 6 deletions src/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,8 @@ class RedirectToProject extends React.Component {
if (resp.topic) {
const topic = resp.topic
const projectId = topic.referenceId
if (topic.tag === PROJECT_FEED_TYPE_PRIMARY) {
history.replace(`/projects/${projectId}/`)
} else if (topic.tag === PROJECT_FEED_TYPE_MESSAGES) {
history.replace({
pathname: `/projects/${projectId}/discussions/${topic.id}`
})
if (topic.tag === PROJECT_FEED_TYPE_PRIMARY || topic.tag === PROJECT_FEED_TYPE_MESSAGES) {
history.replace(`/projects/${projectId}#feed-${topic.id}`)
} else {
history.replace('/projects')
}
Expand Down