summaryrefslogtreecommitdiffstats
path: root/ui/src/components/comment-form.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components/comment-form.tsx')
-rw-r--r--ui/src/components/comment-form.tsx21
1 files changed, 11 insertions, 10 deletions
diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx
index f5816899..b8ea0a5a 100644
--- a/ui/src/components/comment-form.tsx
+++ b/ui/src/components/comment-form.tsx
@@ -10,12 +10,13 @@ import {
} from '../interfaces';
import { Subscription } from 'rxjs';
import {
+ wsJsonToRes,
capitalizeFirstLetter,
mentionDropdownFetchLimit,
- msgOp,
mdToHtml,
randomStr,
markdownHelpUrl,
+ toast,
} from '../utils';
import { WebSocketService, UserService } from '../services';
import autosize from 'autosize';
@@ -293,7 +294,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
.catch(error => {
i.state.imageLoading = false;
i.setState(i.state);
- alert(error);
+ toast(error, 'danger');
});
}
@@ -311,10 +312,10 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
this.userSub = WebSocketService.Instance.subject.subscribe(
msg => {
- let op: UserOperation = msgOp(msg);
- if (op == UserOperation.Search) {
- let res: SearchResponse = msg;
- let users = res.users.map(u => {
+ let res = wsJsonToRes(msg);
+ if (res.op == UserOperation.Search) {
+ let data = res.data as SearchResponse;
+ let users = data.users.map(u => {
return { key: u.name };
});
cb(users);
@@ -343,10 +344,10 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
this.communitySub = WebSocketService.Instance.subject.subscribe(
msg => {
- let op: UserOperation = msgOp(msg);
- if (op == UserOperation.Search) {
- let res: SearchResponse = msg;
- let communities = res.communities.map(u => {
+ let res = wsJsonToRes(msg);
+ if (res.op == UserOperation.Search) {
+ let data = res.data as SearchResponse;
+ let communities = data.communities.map(u => {
return { key: u.name };
});
cb(communities);