2022-08-06 20:39:52 +00:00
|
|
|
import type { JSONContent } from '@tiptap/core'
|
|
|
|
|
2022-09-07 22:09:20 +00:00
|
|
|
export type AnyCommentType = OnContract | OnGroup | OnPost
|
2022-08-19 08:06:40 +00:00
|
|
|
|
2022-01-10 21:07:57 +00:00
|
|
|
// Currently, comments are created after the bet, not atomically with the bet.
|
|
|
|
// They're uniquely identified by the pair contractId/betId.
|
2022-08-19 08:06:40 +00:00
|
|
|
export type Comment<T extends AnyCommentType = AnyCommentType> = {
|
2022-02-04 03:04:56 +00:00
|
|
|
id: string
|
2022-05-11 21:11:46 +00:00
|
|
|
replyToCommentId?: string
|
2022-02-04 03:04:56 +00:00
|
|
|
userId: string
|
|
|
|
|
2022-08-06 20:39:52 +00:00
|
|
|
/** @deprecated - content now stored as JSON in content*/
|
|
|
|
text?: string
|
|
|
|
content: JSONContent
|
2022-01-10 23:52:03 +00:00
|
|
|
createdTime: number
|
2022-02-04 03:04:56 +00:00
|
|
|
|
2022-01-10 21:07:57 +00:00
|
|
|
// Denormalized, for rendering comments
|
2022-03-14 20:29:32 +00:00
|
|
|
userName: string
|
|
|
|
userUsername: string
|
2022-05-06 18:29:15 +00:00
|
|
|
userAvatarUrl?: string
|
2022-09-30 15:27:42 +00:00
|
|
|
bountiesAwarded?: number
|
2022-08-19 08:06:40 +00:00
|
|
|
} & T
|
|
|
|
|
2022-09-07 22:09:20 +00:00
|
|
|
export type OnContract = {
|
2022-08-19 08:06:40 +00:00
|
|
|
commentType: 'contract'
|
|
|
|
contractId: string
|
|
|
|
answerOutcome?: string
|
|
|
|
betId?: string
|
2022-09-04 21:28:45 +00:00
|
|
|
|
|
|
|
// denormalized from contract
|
|
|
|
contractSlug: string
|
|
|
|
contractQuestion: string
|
|
|
|
|
|
|
|
// denormalized from bet
|
|
|
|
betAmount?: number
|
|
|
|
betOutcome?: string
|
2022-09-18 22:57:50 +00:00
|
|
|
|
|
|
|
// denormalized based on betting history
|
|
|
|
commenterPositionProb?: number // binary only
|
|
|
|
commenterPositionShares?: number
|
|
|
|
commenterPositionOutcome?: string
|
2022-01-10 23:52:03 +00:00
|
|
|
}
|
2022-08-19 08:06:40 +00:00
|
|
|
|
2022-09-07 22:09:20 +00:00
|
|
|
export type OnGroup = {
|
2022-08-19 08:06:40 +00:00
|
|
|
commentType: 'group'
|
|
|
|
groupId: string
|
|
|
|
}
|
|
|
|
|
2022-09-07 22:09:20 +00:00
|
|
|
export type OnPost = {
|
|
|
|
commentType: 'post'
|
|
|
|
postId: string
|
|
|
|
}
|
|
|
|
|
2022-08-19 08:06:40 +00:00
|
|
|
export type ContractComment = Comment<OnContract>
|
|
|
|
export type GroupComment = Comment<OnGroup>
|
2022-09-07 22:09:20 +00:00
|
|
|
export type PostComment = Comment<OnPost>
|