Skip to content

Commit 828bf6a

Browse files
authored
Revert "[PROD] Hotfix/fix private topics"
1 parent 56b387a commit 828bf6a

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

src/components/Feed/FeedComments.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class FeedComments extends React.Component {
324324
allMembers={allMembers}
325325
projectMembers={projectMembers}
326326
noInfo={item.noInfo}
327-
canDelete={idx !== comments.length - 1} // cannot delete the first post which is now shown as a last one
327+
canDelete={idx !== 0}
328328
commentAnchorPrefix={commentAnchorPrefix}
329329
>
330330
<div dangerouslySetInnerHTML={{__html: markdownToHTML(itemContent)}} />

src/projects/detail/containers/FeedContainer.js

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ class FeedView extends React.Component {
254254
}
255255

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

283283
onAddNewComment(feedId, content) {
284-
const { currentUser, feeds } = this.props
285-
const feed = _.find(feeds, { id: feedId })
284+
const { currentUser } = this.props
286285
const newComment = {
287286
date: new Date(),
288287
userId: parseInt(currentUser.id),
289288
content
290289
}
291-
this.props.addFeedComment(feedId, feed.tag, newComment)
290+
this.props.addFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, newComment)
292291
}
293292

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

311310
onSaveMessage(feedId, message, content) {
312311
const newMessage = {...message}
313-
const { feeds } = this.state
314-
const feed = _.find(feeds, { id: feedId })
315312
newMessage.content = content
316-
this.props.saveFeedComment(feedId, feed.tag, newMessage)
313+
this.props.saveFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, newMessage)
317314
}
318315

319316
onDeleteMessage(feedId, postId) {
320-
const { feeds } = this.state
321-
const feed = _.find(feeds, { id: feedId })
322-
this.props.deleteFeedComment(feedId, feed.tag, postId)
317+
this.props.deleteFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, postId)
323318
}
324319

325320
onEditMessage(feedId, postId) {
326-
const { feeds } = this.state
327-
const feed = _.find(feeds, { id: feedId })
328-
const comment = _.find(feed.comments, message => message.id === postId)
321+
const thread = _.find(this.state.feeds, t => feedId === t.id)
322+
const comment = _.find(thread.comments, message => message.id === postId)
329323
if (!comment.rawContent) {
330-
this.props.getFeedComment(feedId, feed.tag, postId)
324+
this.props.getFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, postId)
331325
}
332326
this.onSaveMessageChange(feedId, postId, null, true)
333327
}
334328

335329
onEditTopic(feedId) {
336-
const { feeds } = this.state
337-
const feed = _.find(feeds, { id: feedId })
338-
const comment = feed.topicMessage
330+
const thread = _.find(this.state.feeds, t => feedId === t.id)
331+
const comment = thread.topicMessage
339332
if (!comment.rawContent) {
340-
this.props.getFeedComment(feedId, feed.tag, comment.id)
333+
this.props.getFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, comment.id)
341334
}
342335
this.onTopicChange(feedId, comment.id, null, null, true)
343336
}
@@ -357,15 +350,11 @@ class FeedView extends React.Component {
357350
}
358351

359352
onSaveTopic(feedId, postId, title, content) {
360-
const { feeds } = this.state
361-
const feed = _.find(feeds, { id: feedId })
362-
this.props.saveProjectTopic(feedId, feed.tag, {postId, title, content})
353+
this.props.saveProjectTopic(feedId, PROJECT_FEED_TYPE_PRIMARY, {postId, title, content})
363354
}
364355

365356
onDeleteTopic(feedId) {
366-
const { feeds } = this.state
367-
const feed = _.find(feeds, { id: feedId })
368-
this.props.deleteProjectTopic(feedId, feed.tag)
357+
this.props.deleteProjectTopic(feedId, PROJECT_FEED_TYPE_PRIMARY)
369358
}
370359

371360
onRefreshFeeds() {

src/routes.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ class RedirectToProject extends React.Component {
7777
if (resp.topic) {
7878
const topic = resp.topic
7979
const projectId = topic.referenceId
80-
if (topic.tag === PROJECT_FEED_TYPE_PRIMARY || topic.tag === PROJECT_FEED_TYPE_MESSAGES) {
81-
history.replace(`/projects/${projectId}#feed-${topic.id}`)
80+
if (topic.tag === PROJECT_FEED_TYPE_PRIMARY) {
81+
history.replace(`/projects/${projectId}/`)
82+
} else if (topic.tag === PROJECT_FEED_TYPE_MESSAGES) {
83+
history.replace({
84+
pathname: `/projects/${projectId}/discussions/${topic.id}`
85+
})
8286
} else {
8387
history.replace('/projects')
8488
}

0 commit comments

Comments
 (0)