Skip to content

Commit e5b2c37

Browse files
committed
fix actions with private topics
1 parent 5629028 commit e5b2c37

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

src/projects/detail/containers/FeedContainer.js

Lines changed: 26 additions & 15 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.props
258-
const feed = _.find(feeds, feed => feed.id === feedId)
257+
const { feeds } = this.state
258+
const feed = _.find(feeds, { 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, PROJECT_FEED_TYPE_PRIMARY, commentIdsToRetrieve)
274+
this.props.loadFeedComments(feedId, feed.tag, commentIdsToRetrieve)
275275
} else {
276276
this.setState(update(this.state, {
277277
showAll: { $push: [feedId] },
@@ -281,13 +281,14 @@ class FeedView extends React.Component {
281281
}
282282

283283
onAddNewComment(feedId, content) {
284-
const { currentUser } = this.props
284+
const { currentUser, feeds } = this.props
285+
const feed = _.find(feeds, { id: feedId })
285286
const newComment = {
286287
date: new Date(),
287288
userId: parseInt(currentUser.id),
288289
content
289290
}
290-
this.props.addFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, newComment)
291+
this.props.addFeedComment(feedId, feed.tag, newComment)
291292
}
292293

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

310311
onSaveMessage(feedId, message, content) {
311312
const newMessage = {...message}
313+
const { feeds } = this.state
314+
const feed = _.find(feeds, { id: feedId })
312315
newMessage.content = content
313-
this.props.saveFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, newMessage)
316+
this.props.saveFeedComment(feedId, feed.tag, newMessage)
314317
}
315318

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

320325
onEditMessage(feedId, postId) {
321-
const thread = _.find(this.state.feeds, t => feedId === t.id)
322-
const comment = _.find(thread.comments, message => message.id === postId)
326+
const { feeds } = this.state
327+
const feed = _.find(feeds, { id: feedId })
328+
const comment = _.find(feed.comments, message => message.id === postId)
323329
if (!comment.rawContent) {
324-
this.props.getFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, postId)
330+
this.props.getFeedComment(feedId, feed.tag, postId)
325331
}
326332
this.onSaveMessageChange(feedId, postId, null, true)
327333
}
328334

329335
onEditTopic(feedId) {
330-
const thread = _.find(this.state.feeds, t => feedId === t.id)
331-
const comment = thread.topicMessage
336+
const { feeds } = this.state
337+
const feed = _.find(feeds, { id: feedId })
338+
const comment = feed.topicMessage
332339
if (!comment.rawContent) {
333-
this.props.getFeedComment(feedId, PROJECT_FEED_TYPE_PRIMARY, comment.id)
340+
this.props.getFeedComment(feedId, feed.tag, comment.id)
334341
}
335342
this.onTopicChange(feedId, comment.id, null, null, true)
336343
}
@@ -350,11 +357,15 @@ class FeedView extends React.Component {
350357
}
351358

352359
onSaveTopic(feedId, postId, title, content) {
353-
this.props.saveProjectTopic(feedId, PROJECT_FEED_TYPE_PRIMARY, {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})
354363
}
355364

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

360371
onRefreshFeeds() {

src/routes.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ 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) {
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-
})
80+
if (topic.tag === PROJECT_FEED_TYPE_PRIMARY || topic.tag === PROJECT_FEED_TYPE_MESSAGES) {
81+
history.replace(`/projects/${projectId}#feed-${topic.id}`)
8682
} else {
8783
history.replace('/projects')
8884
}

0 commit comments

Comments
 (0)