Skip to content
Merged
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
17 changes: 8 additions & 9 deletions client/state/comments/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getDateSortedPostComments = createSelector(
const comments = getPostCommentItems( state, siteId, postId );
return sortBy( comments, comment => new Date( comment.date ) );
},
( state, siteId, postId ) => [ get( state.comments, 'items' )[ getStateKey( siteId, postId ) ] ]
( state ) => [ state.comments.items ]
);

export const getCommentById = createSelector(
Expand All @@ -40,9 +40,8 @@ export const getCommentById = createSelector(
);
return find( commentsForSite, comment => commentId === comment.ID );
},
( { state, commentId, siteId } ) => [
commentId,
siteId,
( { state } ) => [
state.comments.items,
get( state.comments, 'items' ),
get( state.comments, 'errors' ),
]
Expand All @@ -66,7 +65,7 @@ export const getPostTotalCommentsCount = ( state, siteId, postId ) =>
export const getPostMostRecentCommentDate = createSelector( ( state, siteId, postId ) => {
const items = getPostCommentItems( state, siteId, postId );
return items && first( items ) ? new Date( get( first( items ), 'date' ) ) : undefined;
}, getPostCommentItems );
}, state => state.comments.items );

/***
* Get oldest comment date for a given post
Expand All @@ -78,7 +77,7 @@ export const getPostMostRecentCommentDate = createSelector( ( state, siteId, pos
export const getPostOldestCommentDate = createSelector( ( state, siteId, postId ) => {
const items = getPostCommentItems( state, siteId, postId );
return items && last( items ) ? new Date( get( last( items ), 'date' ) ) : undefined;
}, getPostCommentItems );
}, state => state.comments.items );

/***
* Get newest comment date for a given post
Expand All @@ -90,7 +89,7 @@ export const getPostOldestCommentDate = createSelector( ( state, siteId, postId
export const getPostNewestCommentDate = createSelector( ( state, siteId, postId ) => {
const items = getPostCommentItems( state, siteId, postId );
return items && first( items ) ? new Date( get( first( items ), 'date' ) ) : undefined;
}, getPostCommentItems );
}, state => state.comments.items );

/***
* Gets comment tree for a given post
Expand Down Expand Up @@ -119,7 +118,7 @@ export const getPostCommentsTree = createSelector(
children: map( filter( items, { parent: false } ), 'ID' ).reverse(),
};
},
getPostCommentItems
state => state.comments.items
);

export const commentsFetchingStatus = ( state, siteId, postId, commentTotal = 0 ) => {
Expand Down Expand Up @@ -155,4 +154,4 @@ export const getCommentLike = createSelector( ( state, siteId, postId, commentId
}
const { i_like, like_count } = comment;
return { i_like, like_count };
}, getPostCommentItems );
}, state => state.comments.items );