diff --git a/server/src/websocket/server.rs b/server/src/websocket/server.rs index b1d4f13..f26ae0e 100644 --- a/server/src/websocket/server.rs +++ b/server/src/websocket/server.rs @@ -291,6 +291,7 @@ impl Handler for ChatServer { Err(e) => e.to_string(), }; + println!("Message Sent: {}", msg_out); MessageResult(msg_out) } } diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 867cfd8..b1da988 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -235,7 +235,7 @@ export class Communities extends Component { parseMessage(msg: WebSocketJsonResponse) { console.log(msg); let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); return; } else if (res.op == UserOperation.ListCommunities) { diff --git a/ui/src/components/community-form.tsx b/ui/src/components/community-form.tsx index 33c63c8..c8d888b 100644 --- a/ui/src/components/community-form.tsx +++ b/ui/src/components/community-form.tsx @@ -261,7 +261,7 @@ export class CommunityForm extends Component< parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); console.log(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); this.state.loading = false; this.setState(this.state); diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 9d02dd8..221c921 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -258,7 +258,7 @@ export class Community extends Component { parseMessage(msg: WebSocketJsonResponse) { console.log(msg); let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); this.context.router.history.push('/'); return; diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx index 5c3ff6d..ba5cc6a 100644 --- a/ui/src/components/inbox.tsx +++ b/ui/src/components/inbox.tsx @@ -324,7 +324,7 @@ export class Inbox extends Component { parseMessage(msg: WebSocketJsonResponse) { console.log(msg); let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); return; } else if (res.op == UserOperation.GetReplies) { diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx index ac60ba7..64687a3 100644 --- a/ui/src/components/login.tsx +++ b/ui/src/components/login.tsx @@ -295,7 +295,7 @@ export class Login extends Component { parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); this.state = this.emptyState; this.setState(this.state); diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 9f16edb..6bf4164 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -566,7 +566,7 @@ export class Main extends Component { parseMessage(msg: WebSocketJsonResponse) { console.log(msg); let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); return; } else if (res.op == UserOperation.GetFollowedCommunities) { diff --git a/ui/src/components/modlog.tsx b/ui/src/components/modlog.tsx index dd65109..e03f1ff 100644 --- a/ui/src/components/modlog.tsx +++ b/ui/src/components/modlog.tsx @@ -425,7 +425,7 @@ export class Modlog extends Component { parseMessage(msg: WebSocketJsonResponse) { console.log(msg); let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); return; } else if (res.op == UserOperation.GetModlog) { diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index 849822a..18ba98c 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -202,8 +202,8 @@ export class Navbar extends Component { parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); - if (res.error) { - if (res.error == 'not_logged_in') { + if (msg.error) { + if (msg.error == 'not_logged_in') { UserService.Instance.logout(); location.reload(); } diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index 677007c..ebc7d7b 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -475,7 +475,7 @@ export class PostForm extends Component { parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); this.state.loading = false; this.setState(this.state); diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index 931ced2..f57d891 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -345,7 +345,7 @@ export class Post extends Component { parseMessage(msg: WebSocketJsonResponse) { console.log(msg); let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); return; } else if (res.op == UserOperation.GetPost) { diff --git a/ui/src/components/private-message-form.tsx b/ui/src/components/private-message-form.tsx index c862784..13b4d2e 100644 --- a/ui/src/components/private-message-form.tsx +++ b/ui/src/components/private-message-form.tsx @@ -283,7 +283,7 @@ export class PrivateMessageForm extends Component< parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); this.state.loading = false; this.setState(this.state); diff --git a/ui/src/components/search.tsx b/ui/src/components/search.tsx index 18b5d34..604c261 100644 --- a/ui/src/components/search.tsx +++ b/ui/src/components/search.tsx @@ -479,7 +479,7 @@ export class Search extends Component { parseMessage(msg: WebSocketJsonResponse) { console.log(msg); let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); return; } else if (res.op == UserOperation.Search) { diff --git a/ui/src/components/setup.tsx b/ui/src/components/setup.tsx index 26475a3..25cfade 100644 --- a/ui/src/components/setup.tsx +++ b/ui/src/components/setup.tsx @@ -188,7 +188,7 @@ export class Setup extends Component { parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); this.state.userLoading = false; this.setState(this.state); diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index 09129d6..1475de6 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -1016,12 +1016,12 @@ export class User extends Component { parseMessage(msg: WebSocketJsonResponse) { console.log(msg); let res = wsJsonToRes(msg); - if (res.error) { + if (msg.error) { toast(i18n.t(msg.error), 'danger'); this.state.deleteAccountLoading = false; this.state.avatarLoading = false; this.state.userSettingsLoading = false; - if (res.error == 'couldnt_find_that_username_or_email') { + if (msg.error == 'couldnt_find_that_username_or_email') { this.context.router.history.push('/'); } this.setState(this.state); diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index bd954d2..cd3961b 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -784,11 +784,10 @@ type ResponseType = export interface WebSocketResponse { op: UserOperation; data: ResponseType; - error?: string; } export interface WebSocketJsonResponse { - op: string; - data: ResponseType; + op?: string; + data?: ResponseType; error?: string; }