From 828bf6a66223b25adf3b26f9e8671d08801fdb55 Mon Sep 17 00:00:00 2001 From: RishiRajSahu Date: Wed, 24 Apr 2019 14:55:14 +0530 Subject: [PATCH] Revert "[PROD] Hotfix/fix private topics" --- src/components/Feed/FeedComments.jsx | 2 +- .../detail/containers/FeedContainer.js | 41 +++++++------------ src/routes.jsx | 8 +++- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/components/Feed/FeedComments.jsx b/src/components/Feed/FeedComments.jsx index da73a6984..6f47bfa52 100644 --- a/src/components/Feed/FeedComments.jsx +++ b/src/components/Feed/FeedComments.jsx @@ -324,7 +324,7 @@ class FeedComments extends React.Component { allMembers={allMembers} projectMembers={projectMembers} noInfo={item.noInfo} - canDelete={idx !== comments.length - 1} // cannot delete the first post which is now shown as a last one + canDelete={idx !== 0} commentAnchorPrefix={commentAnchorPrefix} >
diff --git a/src/projects/detail/containers/FeedContainer.js b/src/projects/detail/containers/FeedContainer.js index cc291b038..75e9367f3 100644 --- a/src/projects/detail/containers/FeedContainer.js +++ b/src/projects/detail/containers/FeedContainer.js @@ -254,8 +254,8 @@ class FeedView extends React.Component { } onShowAllComments(feedId) { - const { feeds } = this.state - const feed = _.find(feeds, { id: feedId }) + const { feeds } = this.props + const feed = _.find(feeds, feed => feed.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. @@ -271,7 +271,7 @@ class FeedView extends React.Component { showAll: { $push: [feedId] }, feeds: { $splice: [[stateFeedIdx, 1, updatedFeed ]] } })) - this.props.loadFeedComments(feedId, feed.tag, commentIdsToRetrieve) + this.props.loadFeedComments(feedId, PROJECT_FEED_TYPE_PRIMARY, commentIdsToRetrieve) } else { this.setState(update(this.state, { showAll: { $push: [feedId] }, @@ -281,14 +281,13 @@ class FeedView extends React.Component { } onAddNewComment(feedId, content) { - const { currentUser, feeds } = this.props - const feed = _.find(feeds, { id: feedId }) + const { currentUser } = this.props const newComment = { date: new Date(), userId: parseInt(currentUser.id), content } - this.props.addFeedComment(feedId, feed.tag, newComment) + this.props.addFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, newComment) } onSaveMessageChange(feedId, messageId, content, editMode) { @@ -310,34 +309,28 @@ 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, feed.tag, newMessage) + this.props.saveFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, newMessage) } onDeleteMessage(feedId, postId) { - const { feeds } = this.state - const feed = _.find(feeds, { id: feedId }) - this.props.deleteFeedComment(feedId, feed.tag, postId) + this.props.deleteFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, postId) } onEditMessage(feedId, postId) { - const { feeds } = this.state - const feed = _.find(feeds, { id: feedId }) - const comment = _.find(feed.comments, message => message.id === postId) + const thread = _.find(this.state.feeds, t => feedId === t.id) + const comment = _.find(thread.comments, message => message.id === postId) if (!comment.rawContent) { - this.props.getFeedComment(feedId, feed.tag, postId) + this.props.getFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, postId) } this.onSaveMessageChange(feedId, postId, null, true) } onEditTopic(feedId) { - const { feeds } = this.state - const feed = _.find(feeds, { id: feedId }) - const comment = feed.topicMessage + const thread = _.find(this.state.feeds, t => feedId === t.id) + const comment = thread.topicMessage if (!comment.rawContent) { - this.props.getFeedComment(feedId, feed.tag, comment.id) + this.props.getFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, comment.id) } this.onTopicChange(feedId, comment.id, null, null, true) } @@ -357,15 +350,11 @@ class FeedView extends React.Component { } onSaveTopic(feedId, postId, title, content) { - const { feeds } = this.state - const feed = _.find(feeds, { id: feedId }) - this.props.saveProjectTopic(feedId, feed.tag, {postId, title, content}) + this.props.saveProjectTopic(feedId, PROJECT_FEED_TYPE_PRIMARY, {postId, title, content}) } onDeleteTopic(feedId) { - const { feeds } = this.state - const feed = _.find(feeds, { id: feedId }) - this.props.deleteProjectTopic(feedId, feed.tag) + this.props.deleteProjectTopic(feedId, PROJECT_FEED_TYPE_PRIMARY) } onRefreshFeeds() { diff --git a/src/routes.jsx b/src/routes.jsx index 19274b59b..f28d622de 100644 --- a/src/routes.jsx +++ b/src/routes.jsx @@ -77,8 +77,12 @@ class RedirectToProject extends React.Component { if (resp.topic) { const topic = resp.topic const projectId = topic.referenceId - if (topic.tag === PROJECT_FEED_TYPE_PRIMARY || topic.tag === PROJECT_FEED_TYPE_MESSAGES) { - history.replace(`/projects/${projectId}#feed-${topic.id}`) + 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}` + }) } else { history.replace('/projects') }