add recent comments
This commit is contained in:
parent
db953bd41b
commit
ccb5a81dd5
|
@ -236,6 +236,15 @@ export default {
|
|||
|
||||
let comments, user
|
||||
switch (sort) {
|
||||
case 'recent':
|
||||
comments = await models.$queryRaw(`
|
||||
${SELECT}
|
||||
FROM "Item"
|
||||
WHERE "parentId" IS NOT NULL AND created_at <= $1
|
||||
ORDER BY created_at DESC
|
||||
OFFSET $2
|
||||
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
||||
break
|
||||
case 'user':
|
||||
if (!name) {
|
||||
throw new UserInputError('must supply name', { argumentName: 'name' })
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import Layout from '../../components/layout'
|
||||
import { getGetServerSideProps } from '../../api/ssrApollo'
|
||||
import { MORE_FLAT_COMMENTS } from '../../fragments/comments'
|
||||
import CommentsFlat from '../../components/comments-flat'
|
||||
|
||||
const variables = { sort: 'recent' }
|
||||
export const getServerSideProps = getGetServerSideProps(MORE_FLAT_COMMENTS, variables)
|
||||
|
||||
export default function Index ({ data: { moreFlatComments: { comments, cursor } } }) {
|
||||
return (
|
||||
<Layout>
|
||||
<CommentsFlat
|
||||
comments={comments} cursor={cursor}
|
||||
variables={{ sort: 'recent' }} includeParent noReply
|
||||
/>
|
||||
</Layout>
|
||||
)
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import Layout from '../components/layout'
|
||||
import Items from '../components/items'
|
||||
import { getGetServerSideProps } from '../api/ssrApollo'
|
||||
import { ITEMS } from '../fragments/items'
|
||||
import Layout from '../../components/layout'
|
||||
import Items from '../../components/items'
|
||||
import { getGetServerSideProps } from '../../api/ssrApollo'
|
||||
import { ITEMS } from '../../fragments/items'
|
||||
|
||||
const variables = { sort: 'recent' }
|
||||
export const getServerSideProps = getGetServerSideProps(ITEMS, variables)
|
Loading…
Reference in New Issue