summaryrefslogtreecommitdiffstats
path: root/ui/src/components/private-message-form.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-23 19:17:42 -0500
committerDessalines <tyhou13@gmx.com>2020-01-23 19:17:42 -0500
commitac1d5f2b86b0816cc9b5794dc6c38a38365ed839 (patch)
treebedaab04ca797113990e5702cad36f5e34e9e6e8 /ui/src/components/private-message-form.tsx
parent39d1fb4450cb418d9c11b31ea99484c2a177fab6 (diff)
parentb45c83682c187737b092080e83ba741c39cfa695 (diff)
Done merging http-api and private_message
Diffstat (limited to 'ui/src/components/private-message-form.tsx')
-rw-r--r--ui/src/components/private-message-form.tsx29
1 files changed, 15 insertions, 14 deletions
diff --git a/ui/src/components/private-message-form.tsx b/ui/src/components/private-message-form.tsx
index 96bd807d..5ee1c1fd 100644
--- a/ui/src/components/private-message-form.tsx
+++ b/ui/src/components/private-message-form.tsx
@@ -13,15 +13,16 @@ import {
UserDetailsResponse,
GetUserDetailsForm,
SortType,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService } from '../services';
import {
- msgOp,
capitalizeFirstLetter,
markdownHelpUrl,
mdToHtml,
showAvatars,
pictshareAvatarThumbnail,
+ wsJsonToRes,
toast,
} from '../utils';
import autosize from 'autosize';
@@ -266,26 +267,26 @@ export class PrivateMessageForm extends Component<
i.setState(i.state);
}
- parseMessage(msg: any) {
- let op: UserOperation = msgOp(msg);
- if (msg.error) {
+ parseMessage(msg: WebSocketJsonResponse) {
+ let res = wsJsonToRes(msg);
+ if (res.error) {
toast(i18n.t(msg.error), 'danger');
this.state.loading = false;
this.setState(this.state);
return;
- } else if (op == UserOperation.EditPrivateMessage) {
+ } else if (res.op == UserOperation.EditPrivateMessage) {
+ let data = res.data as PrivateMessageResponse;
this.state.loading = false;
- let res: PrivateMessageResponse = msg;
- this.props.onEdit(res.message);
- } else if (op == UserOperation.GetUserDetails) {
- let res: UserDetailsResponse = msg;
- this.state.recipient = res.user;
- this.state.privateMessageForm.recipient_id = res.user.id;
+ this.props.onEdit(data.message);
+ } else if (res.op == UserOperation.GetUserDetails) {
+ let data = res.data as UserDetailsResponse;
+ this.state.recipient = data.user;
+ this.state.privateMessageForm.recipient_id = data.user.id;
this.setState(this.state);
- } else if (op == UserOperation.CreatePrivateMessage) {
+ } else if (res.op == UserOperation.CreatePrivateMessage) {
+ let data = res.data as PrivateMessageResponse;
this.state.loading = false;
- let res: PrivateMessageResponse = msg;
- this.props.onCreate(res.message);
+ this.props.onCreate(data.message);
this.setState(this.state);
}
}