From e4a3095cb469d4f1e3641992fa1af745d27fe99e Mon Sep 17 00:00:00 2001 From: keyan Date: Sun, 19 Mar 2023 10:43:33 -0500 Subject: [PATCH] give pinned item recent sort by default --- api/resolvers/item.js | 2 +- components/comments.js | 8 ++++---- components/item-full.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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 &&
- +
} )