summaryrefslogtreecommitdiffstats
path: root/ui/src/components/login.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-22 22:29:11 -0500
committerDessalines <tyhou13@gmx.com>2020-01-22 22:29:11 -0500
commit3b4258096c3c3dc160090436c9205e1ecf2e8e75 (patch)
treef07264d3de3b169c6140b2bf303ff7732d908b0a /ui/src/components/login.tsx
parent66af9623d90aadd47c9cf37faeac4f60f1d818d4 (diff)
Adding a toaster to replace alerts. Fixes #457
Diffstat (limited to 'ui/src/components/login.tsx')
-rw-r--r--ui/src/components/login.tsx16
1 files changed, 5 insertions, 11 deletions
diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx
index 53b7a22f..0c8350aa 100644
--- a/ui/src/components/login.tsx
+++ b/ui/src/components/login.tsx
@@ -10,7 +10,7 @@ import {
GetSiteResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { msgOp, validEmail } from '../utils';
+import { msgOp, validEmail, toast } from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
@@ -48,14 +48,7 @@ export class Login extends Component<any, State> {
this.state = this.emptyState;
this.subscription = WebSocketService.Instance.subject
- .pipe(
- retryWhen(errors =>
- errors.pipe(
- delay(3000),
- take(10)
- )
- )
- )
+ .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
.subscribe(
msg => this.parseMessage(msg),
err => console.error(err),
@@ -302,7 +295,7 @@ export class Login extends Component<any, State> {
parseMessage(msg: any) {
let op: UserOperation = msgOp(msg);
if (msg.error) {
- alert(i18n.t(msg.error));
+ toast(i18n.t(msg.error), 'danger');
this.state = this.emptyState;
this.setState(this.state);
return;
@@ -312,6 +305,7 @@ export class Login extends Component<any, State> {
this.setState(this.state);
let res: LoginResponse = msg;
UserService.Instance.login(res);
+ toast(i18n.t('logged_in'));
this.props.history.push('/');
} else if (op == UserOperation.Register) {
this.state = this.emptyState;
@@ -320,7 +314,7 @@ export class Login extends Component<any, State> {
UserService.Instance.login(res);
this.props.history.push('/communities');
} else if (op == UserOperation.PasswordReset) {
- alert(i18n.t('reset_password_mail_sent'));
+ toast(i18n.t('reset_password_mail_sent'));
} else if (op == UserOperation.GetSite) {
let res: GetSiteResponse = msg;
this.state.enable_nsfw = res.site.enable_nsfw;