give pinned item recent sort by default
This commit is contained in:
parent
ff34bd0124
commit
e4a3095cb4
|
@ -892,7 +892,7 @@ export default {
|
||||||
if (item.comments) {
|
if (item.comments) {
|
||||||
return 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 }) => {
|
upvotes: async (item, args, { models }) => {
|
||||||
const [{ count }] = await models.$queryRaw(`
|
const [{ count }] = await models.$queryRaw(`
|
||||||
|
|
|
@ -7,8 +7,8 @@ import { COMMENTS_QUERY } from '../fragments/items'
|
||||||
import { COMMENTS } from '../fragments/comments'
|
import { COMMENTS } from '../fragments/comments'
|
||||||
import { abbrNum } from '../lib/format'
|
import { abbrNum } from '../lib/format'
|
||||||
|
|
||||||
export function CommentsHeader ({ handleSort, commentSats }) {
|
export function CommentsHeader ({ handleSort, pinned, commentSats }) {
|
||||||
const [sort, setSort] = useState('hot')
|
const [sort, setSort] = useState(pinned ? 'recent' : 'hot')
|
||||||
|
|
||||||
const getHandleClick = sort => {
|
const getHandleClick = sort => {
|
||||||
return () => {
|
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()
|
const client = useApolloClient()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const hash = window.location.hash
|
const hash = window.location.hash
|
||||||
|
@ -97,7 +97,7 @@ export default function Comments ({ parentId, commentSats, comments, ...props })
|
||||||
<>
|
<>
|
||||||
{comments.length
|
{comments.length
|
||||||
? <CommentsHeader
|
? <CommentsHeader
|
||||||
commentSats={commentSats} handleSort={sort => {
|
commentSats={commentSats} pinned={pinned} handleSort={sort => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
getComments({ variables: { id: parentId, sort } })
|
getComments({ variables: { id: parentId, sort } })
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -169,7 +169,7 @@ export default function ItemFull ({ item, bio, ...props }) {
|
||||||
</div>)}
|
</div>)}
|
||||||
{item.comments &&
|
{item.comments &&
|
||||||
<div className={styles.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>}
|
</div>}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue