summaryrefslogtreecommitdiffstats
path: root/ui/src/components/user.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-02-07 23:05:15 -0500
committerDessalines <tyhou13@gmx.com>2020-02-07 23:05:15 -0500
commitecd10482a6815fc3b51b2da7cd5f494c01c385e6 (patch)
tree16d25467ba4224bfd807122806d1f77ddfaee6e8 /ui/src/components/user.tsx
parent779a72581c4c1dee846296cd0f3ea761914aedc6 (diff)
Add new comments views to main and community pages. Fixes #480
Diffstat (limited to 'ui/src/components/user.tsx')
-rw-r--r--ui/src/components/user.tsx30
1 files changed, 17 insertions, 13 deletions
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx
index da6aa8ce..effc9e1d 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -1034,20 +1034,24 @@ export class User extends Component<any, UserState> {
let data = res.data as CommentResponse;
let found = this.state.comments.find(c => c.id == data.comment.id);
- found.content = data.comment.content;
- found.updated = data.comment.updated;
- found.removed = data.comment.removed;
- found.deleted = data.comment.deleted;
- found.upvotes = data.comment.upvotes;
- found.downvotes = data.comment.downvotes;
- found.score = data.comment.score;
-
- this.setState(this.state);
+ if (found) {
+ found.content = data.comment.content;
+ found.updated = data.comment.updated;
+ found.removed = data.comment.removed;
+ found.deleted = data.comment.deleted;
+ found.upvotes = data.comment.upvotes;
+ found.downvotes = data.comment.downvotes;
+ found.score = data.comment.score;
+ this.setState(this.state);
+ }
} else if (res.op == UserOperation.CreateComment) {
- // let res: CommentResponse = msg;
- toast(i18n.t('reply_sent'));
- // this.state.comments.unshift(res.comment); // TODO do this right
- // this.setState(this.state);
+ let data = res.data as CommentResponse;
+ if (
+ UserService.Instance.user &&
+ data.comment.creator_id == UserService.Instance.user.id
+ ) {
+ toast(i18n.t('reply_sent'));
+ }
} else if (res.op == UserOperation.SaveComment) {
let data = res.data as CommentResponse;
let found = this.state.comments.find(c => c.id == data.comment.id);