@@ -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 ( ) {
0 commit comments