diff --git a/src/components/SearchInfo.jsx b/src/components/SearchInfo.jsx index 6c2e061f..fc766cbd 100644 --- a/src/components/SearchInfo.jsx +++ b/src/components/SearchInfo.jsx @@ -16,7 +16,7 @@ function SearchInfo({ onClear, }) { return ( -
+
@@ -126,6 +132,7 @@ function PostLink({
+ {!showDivider && post.pinned &&
} ); @@ -142,7 +149,7 @@ PostLink.propTypes = { PostLink.defaultProps = { learnerTab: false, - showDivider: false, + showDivider: true, idx: -1, }; diff --git a/src/discussions/utils.js b/src/discussions/utils.js index bafca548..28f4b964 100644 --- a/src/discussions/utils.js +++ b/src/discussions/utils.js @@ -1,5 +1,6 @@ /* eslint-disable import/prefer-default-export */ import { getIn } from 'formik'; +import { orderBy, uniqBy } from 'lodash'; import { generatePath, useRouteMatch } from 'react-router'; import { getConfig } from '@edx/frontend-platform'; @@ -238,3 +239,17 @@ export const isPostPreviewAvailable = (htmlNode) => { } return true; }; + +/** + * Helper function to filter posts + * @param {array} posts arrays of posts + * @param {string} filterBy name of post object attribute. un will use for reverse + * condition. like pinned attribute for pinned post and unpinned for non pinned posts. + * @param {string} sortBy name of post object attribute + * @param {string} order order of the sorting list + */ +export const filterPosts = (posts, filterBy, sortBy = 'createdAt', order = 'desc') => orderBy( + uniqBy(posts, 'id').filter( + post => (filterBy.startsWith('un') ? !post[filterBy.slice(2)] : post[filterBy]), + ), [sortBy], [order], +); diff --git a/src/index.scss b/src/index.scss index e8745223..62f69192 100755 --- a/src/index.scss +++ b/src/index.scss @@ -160,4 +160,8 @@ header { .pointer-cursor-hover :hover{ cursor: pointer; -} \ No newline at end of file +} + +.filter-bar:focus-visible, .filter-bar:focus { + outline: none; +}