Fixing front end error messages. Fixes #462

This commit is contained in:
Dessalines 2020-01-25 09:58:53 -05:00
parent 691d05222b
commit aa5a911edc
16 changed files with 19 additions and 19 deletions

View file

@ -291,6 +291,7 @@ impl Handler<StandardMessage> for ChatServer {
Err(e) => e.to_string(),
};
println!("Message Sent: {}", msg_out);
MessageResult(msg_out)
}
}

View file

@ -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) {

View file

@ -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);

View file

@ -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;

View file

@ -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) {

View file

@ -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);

View file

@ -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) {

View file

@ -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) {

View file

@ -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();
}

View file

@ -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);

View file

@ -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) {

View file

@ -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);

View file

@ -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) {

View file

@ -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);

View file

@ -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);

View file

@ -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;
}