summaryrefslogtreecommitdiffstats
path: root/ui/src
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-25 09:58:53 -0500
committerDessalines <tyhou13@gmx.com>2020-01-25 09:58:53 -0500
commitaa5a911edc9d78cb0c462bbd525287e0f3a122ec (patch)
tree850ef9040582f0e140d103a5b4bfe87e8b116e71 /ui/src
parent691d05222bc1009ec7373336ee097b2bcda5ada5 (diff)
Fixing front end error messages. Fixes #462
Diffstat (limited to 'ui/src')
-rw-r--r--ui/src/components/communities.tsx2
-rw-r--r--ui/src/components/community-form.tsx2
-rw-r--r--ui/src/components/community.tsx2
-rw-r--r--ui/src/components/inbox.tsx2
-rw-r--r--ui/src/components/login.tsx2
-rw-r--r--ui/src/components/main.tsx2
-rw-r--r--ui/src/components/modlog.tsx2
-rw-r--r--ui/src/components/navbar.tsx4
-rw-r--r--ui/src/components/post-form.tsx2
-rw-r--r--ui/src/components/post.tsx2
-rw-r--r--ui/src/components/private-message-form.tsx2
-rw-r--r--ui/src/components/search.tsx2
-rw-r--r--ui/src/components/setup.tsx2
-rw-r--r--ui/src/components/user.tsx4
-rw-r--r--ui/src/interfaces.ts5
15 files changed, 18 insertions, 19 deletions
diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx
index 867cfd81..b1da9882 100644
--- a/ui/src/components/communities.tsx
+++ b/ui/src/components/communities.tsx
@@ -235,7 +235,7 @@ export class Communities extends Component<any, CommunitiesState> {
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 33c63c89..c8d888be 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 9d02dd86..221c9211 100644
--- a/ui/src/components/community.tsx
+++ b/ui/src/components/community.tsx
@@ -258,7 +258,7 @@ export class Community extends Component<any, State> {
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 5c3ff6d2..ba5cc6ad 100644
--- a/ui/src/components/inbox.tsx
+++ b/ui/src/components/inbox.tsx
@@ -324,7 +324,7 @@ export class Inbox extends Component<any, InboxState> {
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 ac60ba74..64687a3d 100644
--- a/ui/src/components/login.tsx
+++ b/ui/src/components/login.tsx
@@ -295,7 +295,7 @@ export class Login extends Component<any, State> {
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 9f16edb5..6bf4164f 100644
--- a/ui/src/components/main.tsx
+++ b/ui/src/components/main.tsx
@@ -566,7 +566,7 @@ export class Main extends Component<any, MainState> {
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 dd651092..e03f1ff7 100644
--- a/ui/src/components/modlog.tsx
+++ b/ui/src/components/modlog.tsx
@@ -425,7 +425,7 @@ export class Modlog extends Component<any, ModlogState> {
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 849822af..18ba98c9 100644
--- a/ui/src/components/navbar.tsx
+++ b/ui/src/components/navbar.tsx
@@ -202,8 +202,8 @@ export class Navbar extends Component<any, NavbarState> {
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 677007ca..ebc7d7b7 100644
--- a/ui/src/components/post-form.tsx
+++ b/ui/src/components/post-form.tsx
@@ -475,7 +475,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
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 931ced2d..f57d8913 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -345,7 +345,7 @@ export class Post extends Component<any, PostState> {
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 c8627845..13b4d2ea 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 18b5d341..604c2617 100644
--- a/ui/src/components/search.tsx
+++ b/ui/src/components/search.tsx
@@ -479,7 +479,7 @@ export class Search extends Component<any, SearchState> {
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 26475a38..25cfadef 100644
--- a/ui/src/components/setup.tsx
+++ b/ui/src/components/setup.tsx
@@ -188,7 +188,7 @@ export class Setup extends Component<any, State> {
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 09129d67..1475de6b 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -1016,12 +1016,12 @@ export class User extends Component<any, UserState> {
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 bd954d20..cd3961b5 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;
}