summaryrefslogtreecommitdiffstats
path: root/ui/src/components/inbox.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-31 22:34:08 -0500
committerDessalines <tyhou13@gmx.com>2020-01-31 22:34:08 -0500
commit8ec104cb762f58e83fde262ee25c23ddf49730bf (patch)
tree880fd0f56ac033ade8e70825f808d82c22dc4d93 /ui/src/components/inbox.tsx
parent8036474ddad2f20c27a2fb023395306d6b9e577d (diff)
Mostly done eliminating recurring fetches.
Diffstat (limited to 'ui/src/components/inbox.tsx')
-rw-r--r--ui/src/components/inbox.tsx24
1 files changed, 19 insertions, 5 deletions
diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx
index 5585d84f..5fd9dbdc 100644
--- a/ui/src/components/inbox.tsx
+++ b/ui/src/components/inbox.tsx
@@ -421,11 +421,25 @@ export class Inbox extends Component<any, InboxState> {
this.sendUnreadCount();
this.setState(this.state);
} else if (res.op == UserOperation.CreateComment) {
- // let res: CommentResponse = msg;
- // TODO gotta remove this
- toast(i18n.t('reply_sent'));
- // this.state.replies.unshift(res.comment); // TODO do this right
- // this.setState(this.state);
+ let data = res.data as CommentResponse;
+
+ if (data.recipient_ids.includes(UserService.Instance.user.id)) {
+ this.state.replies.unshift(data.comment);
+ this.setState(this.state);
+ } else if (data.comment.creator_id == UserService.Instance.user.id) {
+ toast(i18n.t('reply_sent'));
+ }
+ this.setState(this.state);
+ } else if (res.op == UserOperation.CreatePrivateMessage) {
+ let data = res.data as PrivateMessageResponse;
+
+ if (data.message.recipient_id == UserService.Instance.user.id) {
+ this.state.messages.unshift(data.message);
+ this.setState(this.state);
+ } else if (data.message.creator_id == UserService.Instance.user.id) {
+ toast(i18n.t('message_sent'));
+ }
+ this.setState(this.state);
} else if (res.op == UserOperation.SaveComment) {
let data = res.data as CommentResponse;
let found = this.state.replies.find(c => c.id == data.comment.id);