From f7769bb14eacc66865ef1efc04afc6d048589c12 Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Wed, 20 Jan 2021 09:47:08 -0800 Subject: [PATCH] Use modifiedBy for comment author --- server/app/auth.go | 2 +- webapp/src/blocks/block.ts | 4 ++++ webapp/src/blocks/commentBlock.ts | 13 +------------ webapp/src/components/cardDetail.tsx | 15 +++++---------- webapp/src/components/commentsList.tsx | 6 ++---- 5 files changed, 13 insertions(+), 27 deletions(-) diff --git a/server/app/auth.go b/server/app/auth.go index 45779bda0..7bf89b92f 100644 --- a/server/app/auth.go +++ b/server/app/auth.go @@ -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 } diff --git a/webapp/src/blocks/block.ts b/webapp/src/blocks/block.ts index 070b98ead..a9e165b6d 100644 --- a/webapp/src/blocks/block.ts +++ b/webapp/src/blocks/block.ts @@ -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 = {} @@ -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. diff --git a/webapp/src/blocks/commentBlock.ts b/webapp/src/blocks/commentBlock.ts index 31662d43d..41bafb0af 100644 --- a/webapp/src/blocks/commentBlock.ts +++ b/webapp/src/blocks/commentBlock.ts @@ -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 || '' } } diff --git a/webapp/src/components/cardDetail.tsx b/webapp/src/components/cardDetail.tsx index 22248320d..a722e8f9c 100644 --- a/webapp/src/components/cardDetail.tsx +++ b/webapp/src/components/cardDetail.tsx @@ -195,16 +195,11 @@ class CardDetail extends React.Component { {!this.props.readonly && <>
- - {(user) => (user && - - )} - +
} diff --git a/webapp/src/components/commentsList.tsx b/webapp/src/components/commentsList.tsx index 2b6939e34..35fa8e70a 100644 --- a/webapp/src/components/commentsList.tsx +++ b/webapp/src/components/commentsList.tsx @@ -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 { } 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 { key={comment.id} comment={comment} userImageUrl={userImageUrl} - userId={comment.userId} + userId={comment.modifiedBy} /> ))}