Use modifiedBy for comment author

This commit is contained in:
Chen-I Lim 2021-01-20 09:47:08 -08:00
parent c5cb542d7e
commit f7769bb14e
5 changed files with 13 additions and 27 deletions

View file

@ -40,7 +40,7 @@ func (a *App) GetUser(ID string) (*model.User, error) {
user, err := a.store.GetUserById(ID)
if err != nil {
return nil, errors.Wrap(err, "unable to get the session for the user")
return nil, errors.Wrap(err, "unable to find user")
}
return user, nil
}

View file

@ -8,6 +8,7 @@ interface IBlock {
readonly id: string
readonly parentId: string
readonly rootId: string
readonly modifiedBy: string
readonly schema: number
readonly type: BlockTypes
@ -23,6 +24,7 @@ interface IMutableBlock extends IBlock {
id: string
parentId: string
rootId: string
modifiedBy: string
schema: number
type: BlockTypes
@ -39,6 +41,7 @@ class MutableBlock implements IMutableBlock {
schema: number
parentId: string
rootId: string
modifiedBy: string
type: BlockTypes
title: string
fields: Record<string, any> = {}
@ -63,6 +66,7 @@ class MutableBlock implements IMutableBlock {
this.schema = 1
this.parentId = block.parentId || ''
this.rootId = block.rootId || ''
this.modifiedBy = block.modifiedBy || ''
this.type = block.type || ''
// Shallow copy here. Derived classes must make deep copies of their known properties in their constructors.

View file

@ -4,23 +4,12 @@ import {IBlock} from '../blocks/block'
import {MutableBlock} from './block'
interface CommentBlock extends IBlock {
readonly userId: string
}
type CommentBlock = IBlock
class MutableCommentBlock extends MutableBlock implements CommentBlock {
get userId(): string {
return this.fields.userId as string
}
set userId(value: string) {
this.fields.userId = value
}
constructor(block: any = {}) {
super(block)
this.type = 'comment'
this.userId = block.fields?.userId || ''
}
}

View file

@ -195,16 +195,11 @@ class CardDetail extends React.Component<Props, State> {
{!this.props.readonly &&
<>
<hr/>
<UserContext.Consumer>
{(user) => (user &&
<CommentsList
comments={comments}
userId={user.id}
rootId={card.rootId}
cardId={card.id}
/>
)}
</UserContext.Consumer>
<CommentsList
comments={comments}
rootId={card.rootId}
cardId={card.id}
/>
<hr/>
</>
}

View file

@ -14,7 +14,6 @@ import {MarkdownEditor} from './markdownEditor'
type Props = {
comments: readonly CommentBlock[]
userId: string
rootId: string
cardId: string
intl: IntlShape
@ -39,14 +38,13 @@ class CommentsList extends React.Component<Props, State> {
}
private sendComment = () => {
const {userId, rootId, cardId} = this.props
const {rootId, cardId} = this.props
Utils.assertValue(cardId)
const comment = new MutableCommentBlock()
comment.parentId = cardId
comment.rootId = rootId
comment.userId = userId
comment.title = this.state.newComment
mutator.insertBlock(comment, 'add comment')
this.setState({newComment: ''})
@ -65,7 +63,7 @@ class CommentsList extends React.Component<Props, State> {
key={comment.id}
comment={comment}
userImageUrl={userImageUrl}
userId={comment.userId}
userId={comment.modifiedBy}
/>
))}