give pinned item recent sort by default

This commit is contained in:
keyan 2023-03-19 10:43:33 -05:00
parent ff34bd0124
commit e4a3095cb4
3 changed files with 6 additions and 6 deletions

View File

@ -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(`

View File

@ -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
? <CommentsHeader
commentSats={commentSats} handleSort={sort => {
commentSats={commentSats} pinned={pinned} handleSort={sort => {
setLoading(true)
getComments({ variables: { id: parentId, sort } })
}}

View File

@ -169,7 +169,7 @@ export default function ItemFull ({ item, bio, ...props }) {
</div>)}
{item.comments &&
<div className={styles.comments}>
<Comments parentId={item.id} commentSats={item.commentSats} comments={item.comments} />
<Comments parentId={item.id} pinned={item.position} commentSats={item.commentSats} comments={item.comments} />
</div>}
</>
)