diff --git a/api/resolvers/item.js b/api/resolvers/item.js index 7ce6ab56..1f21da31 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -892,7 +892,7 @@ export default { if (item.comments) { return item.comments } - return comments(me, models, item.id, 'hot', item) + return comments(me, models, item.id, item.pinId ? 'recent' : 'hot', item) }, upvotes: async (item, args, { models }) => { const [{ count }] = await models.$queryRaw(` diff --git a/components/comments.js b/components/comments.js index 22c16926..68d129be 100644 --- a/components/comments.js +++ b/components/comments.js @@ -7,8 +7,8 @@ import { COMMENTS_QUERY } from '../fragments/items' import { COMMENTS } from '../fragments/comments' import { abbrNum } from '../lib/format' -export function CommentsHeader ({ handleSort, commentSats }) { - const [sort, setSort] = useState('hot') +export function CommentsHeader ({ handleSort, pinned, commentSats }) { + const [sort, setSort] = useState(pinned ? 'recent' : 'hot') const getHandleClick = sort => { return () => { @@ -60,7 +60,7 @@ export function CommentsHeader ({ handleSort, commentSats }) { ) } -export default function Comments ({ parentId, commentSats, comments, ...props }) { +export default function Comments ({ parentId, pinned, commentSats, comments, ...props }) { const client = useApolloClient() useEffect(() => { const hash = window.location.hash @@ -97,7 +97,7 @@ export default function Comments ({ parentId, commentSats, comments, ...props }) <> {comments.length ? { + commentSats={commentSats} pinned={pinned} handleSort={sort => { setLoading(true) getComments({ variables: { id: parentId, sort } }) }} diff --git a/components/item-full.js b/components/item-full.js index c5e7704c..b1282ba6 100644 --- a/components/item-full.js +++ b/components/item-full.js @@ -169,7 +169,7 @@ export default function ItemFull ({ item, bio, ...props }) { )} {item.comments &&
- +
} )