thiigy dissappears after submit

This commit is contained in:
ingawei 2022-10-08 01:34:24 -07:00
parent 0e842ab391
commit f247196973
2 changed files with 49 additions and 7 deletions

View File

@ -1,12 +1,18 @@
import { PaperAirplaneIcon } from '@heroicons/react/solid' import { PaperAirplaneIcon, XIcon } from '@heroicons/react/solid'
import { Editor } from '@tiptap/react' import { Editor } from '@tiptap/react'
import clsx from 'clsx' import clsx from 'clsx'
import { Answer } from 'common/answer'
import { AnyContractType, Contract } from 'common/contract'
import { User } from 'common/user' import { User } from 'common/user'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useEvent } from 'web/hooks/use-event'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { MAX_COMMENT_LENGTH } from 'web/lib/firebase/comments' import { MAX_COMMENT_LENGTH } from 'web/lib/firebase/comments'
import Curve from 'web/public/custom-components/curve'
import { Avatar } from './avatar' import { Avatar } from './avatar'
import { TextEditor, useTextEditor } from './editor' import { TextEditor, useTextEditor } from './editor'
import { CommentsAnswer } from './feed/feed-answer-comment-group'
import { ContractCommentInput, ReplyTo } from './feed/feed-comments'
import { Row } from './layout/row' import { Row } from './layout/row'
import { LoadingIndicator } from './loading-indicator' import { LoadingIndicator } from './loading-indicator'
@ -151,3 +157,42 @@ export function CommentInputTextArea(props: {
</> </>
) )
} }
export function AnswerCommentInput(props: {
contract: Contract<AnyContractType>
answerResponse: Answer
onCancelAnswerResponse?: () => void
}) {
const { contract, answerResponse, onCancelAnswerResponse } = props
// const [replyTo, setReplyTo] = useState<ReplyTo | undefined>({
// id: answerResponse.id,
// username: answerResponse.username,
// })
return (
<>
<Row className="gap-2">
<CommentsAnswer answer={answerResponse} contract={contract} />
</Row>
<Row>
<div className="ml-1">
<Curve size={28} strokeWidth={1} color="#D8D8EB" />
</div>
<div className="w-full pt-1">
<ContractCommentInput
contract={contract}
parentAnswerOutcome={answerResponse.number.toString()}
replyTo={{
id: answerResponse.id,
username: answerResponse.username,
}}
onSubmitComment={onCancelAnswerResponse}
/>
</div>
<button onClick={onCancelAnswerResponse}>
<XIcon className="h-5 w-5" />
</button>
</Row>
</>
)
}

View File

@ -4,12 +4,7 @@ import { Pagination } from 'web/components/pagination'
import { FeedBet } from '../feed/feed-bets' import { FeedBet } from '../feed/feed-bets'
import { FeedLiquidity } from '../feed/feed-liquidity' import { FeedLiquidity } from '../feed/feed-liquidity'
import { CommentsAnswer } from '../feed/feed-answer-comment-group' import { CommentsAnswer } from '../feed/feed-answer-comment-group'
import { import { FeedCommentThread, ContractCommentInput } from '../feed/feed-comments'
FeedCommentThread,
ContractCommentInput,
CommentActions,
AnswerCommentInput,
} from '../feed/feed-comments'
import { groupBy, sortBy, sum } from 'lodash' import { groupBy, sortBy, sum } from 'lodash'
import { Bet } from 'common/bet' import { Bet } from 'common/bet'
import { Contract } from 'common/contract' import { Contract } from 'common/contract'
@ -51,6 +46,7 @@ import { ArrowRightIcon, ReplyIcon, XIcon } from '@heroicons/react/solid'
import Curve from 'web/public/custom-components/curve' import Curve from 'web/public/custom-components/curve'
import { Answer } from 'common/answer' import { Answer } from 'common/answer'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { AnswerCommentInput } from '../comment-input'
export function ContractTabs(props: { export function ContractTabs(props: {
contract: Contract contract: Contract
@ -111,6 +107,7 @@ const CommentsTabContent = memo(function CommentsTabContent(props: {
onCancelAnswerResponse?: () => void onCancelAnswerResponse?: () => void
}) { }) {
const { contract, answerResponse, onCancelAnswerResponse } = props const { contract, answerResponse, onCancelAnswerResponse } = props
console.log(answerResponse)
const tips = useTipTxns({ contractId: contract.id }) const tips = useTipTxns({ contractId: contract.id })
const comments = useComments(contract.id) ?? props.comments const comments = useComments(contract.id) ?? props.comments
const [sort, setSort] = usePersistentState<'Newest' | 'Best'>('Newest', { const [sort, setSort] = usePersistentState<'Newest' | 'Best'>('Newest', {