click to comment goes to root thread
This commit is contained in:
parent
cb3a731785
commit
996d0a9352
@ -374,6 +374,9 @@ export default {
|
|||||||
|
|
||||||
return sats || 0
|
return sats || 0
|
||||||
},
|
},
|
||||||
|
mine: async (item, args, { me, models }) => {
|
||||||
|
return me?.id === item.userId
|
||||||
|
},
|
||||||
meBoost: async (item, args, { me, models }) => {
|
meBoost: async (item, args, { me, models }) => {
|
||||||
if (!me) return 0
|
if (!me) return 0
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ export default gql`
|
|||||||
sats: Int!
|
sats: Int!
|
||||||
boost: Int!
|
boost: Int!
|
||||||
tips: Int!
|
tips: Int!
|
||||||
|
mine: Boolean!
|
||||||
meVote: Int!
|
meVote: Int!
|
||||||
meBoost: Int!
|
meBoost: Int!
|
||||||
meTip: Int!
|
meTip: Int!
|
||||||
|
@ -9,7 +9,6 @@ import UpVote from './upvote'
|
|||||||
import Eye from '../svgs/eye-fill.svg'
|
import Eye from '../svgs/eye-fill.svg'
|
||||||
import EyeClose from '../svgs/eye-close-line.svg'
|
import EyeClose from '../svgs/eye-close-line.svg'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useMe } from './me'
|
|
||||||
import CommentEdit from './comment-edit'
|
import CommentEdit from './comment-edit'
|
||||||
import Countdown from './countdown'
|
import Countdown from './countdown'
|
||||||
import { NOFOLLOW_LIMIT } from '../lib/constants'
|
import { NOFOLLOW_LIMIT } from '../lib/constants'
|
||||||
@ -47,8 +46,7 @@ export default function Comment ({
|
|||||||
const [collapse, setCollapse] = useState(false)
|
const [collapse, setCollapse] = useState(false)
|
||||||
const ref = useRef(null)
|
const ref = useRef(null)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const me = useMe()
|
const mine = item.mine
|
||||||
const mine = me?.id === item.user.id
|
|
||||||
const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000
|
const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000
|
||||||
const [canEdit, setCanEdit] =
|
const [canEdit, setCanEdit] =
|
||||||
useState(mine && (Date.now() < editThreshold))
|
useState(mine && (Date.now() < editThreshold))
|
||||||
|
@ -27,8 +27,8 @@ export default function CommentsFlat ({ variables, comments, cursor, ...props })
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push({
|
router.push({
|
||||||
pathname: '/items/[id]',
|
pathname: '/items/[id]',
|
||||||
query: { id: item.parentId, commentId: item.id }
|
query: { id: item.root.id, commentId: item.id }
|
||||||
}, `/items/${item.parentId}`)
|
}, `/items/${item.root.id}`)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Comment item={item} {...props} />
|
<Comment item={item} {...props} />
|
||||||
|
@ -2,14 +2,12 @@ import Link from 'next/link'
|
|||||||
import styles from './item.module.css'
|
import styles from './item.module.css'
|
||||||
import { timeSince } from '../lib/time'
|
import { timeSince } from '../lib/time'
|
||||||
import UpVote from './upvote'
|
import UpVote from './upvote'
|
||||||
import { useMe } from './me'
|
|
||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import Countdown from './countdown'
|
import Countdown from './countdown'
|
||||||
import { NOFOLLOW_LIMIT } from '../lib/constants'
|
import { NOFOLLOW_LIMIT } from '../lib/constants'
|
||||||
|
|
||||||
export default function Item ({ item, rank, children }) {
|
export default function Item ({ item, rank, children }) {
|
||||||
const me = useMe()
|
const mine = item.mine
|
||||||
const mine = me?.id === item.user.id
|
|
||||||
const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000
|
const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000
|
||||||
const [canEdit, setCanEdit] =
|
const [canEdit, setCanEdit] =
|
||||||
useState(mine && (Date.now() < editThreshold))
|
useState(mine && (Date.now() < editThreshold))
|
||||||
|
@ -14,8 +14,8 @@ function Notification ({ n }) {
|
|||||||
if (n.__typename === 'Reply' || !n.item.title) {
|
if (n.__typename === 'Reply' || !n.item.title) {
|
||||||
router.push({
|
router.push({
|
||||||
pathname: '/items/[id]',
|
pathname: '/items/[id]',
|
||||||
query: { id: n.item.parentId, commentId: n.item.id }
|
query: { id: n.item.root.id, commentId: n.item.id }
|
||||||
}, `/items/${n.item.parentId}`)
|
}, `/items/${n.item.root.id}`)
|
||||||
} else {
|
} else {
|
||||||
router.push({
|
router.push({
|
||||||
pathname: '/items/[id]',
|
pathname: '/items/[id]',
|
||||||
|
@ -84,8 +84,8 @@ export default function UpVote ({ item, className }) {
|
|||||||
return '1 sat'
|
return '1 sat'
|
||||||
}
|
}
|
||||||
|
|
||||||
const noSelfTips = item?.meVote && item?.user?.id === me?.id
|
const noSelfTips = item?.meVote && item?.mine
|
||||||
const Arrow = item?.meVote ? BoltAdd : UpArrow
|
const Arrow = item?.meVote && !item?.mine ? BoltAdd : UpArrow
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LightningConsumer>
|
<LightningConsumer>
|
||||||
|
@ -16,6 +16,7 @@ export const COMMENT_FIELDS = gql`
|
|||||||
meVote
|
meVote
|
||||||
meBoost
|
meBoost
|
||||||
meTip
|
meTip
|
||||||
|
mine
|
||||||
ncomments
|
ncomments
|
||||||
root {
|
root {
|
||||||
id
|
id
|
||||||
|
@ -19,6 +19,7 @@ export const ITEM_FIELDS = gql`
|
|||||||
meBoost
|
meBoost
|
||||||
meTip
|
meTip
|
||||||
ncomments
|
ncomments
|
||||||
|
mine
|
||||||
root {
|
root {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
Loading…
x
Reference in New Issue
Block a user