From cd4e0ab3c2cfd615e4771fb9181a31ce237b5ceb Mon Sep 17 00:00:00 2001
From: Dessalines <tyhou13@gmx.com>
Date: Wed, 8 Jul 2020 01:02:14 -0400
Subject: HTML title bugs.

- Fixing HTML titles for some pages. Fixes #801
- Removing WebSocketService.Instance.site, fetching site on demand now.
---
 ui/src/components/password_change.tsx | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

(limited to 'ui/src/components/password_change.tsx')

diff --git a/ui/src/components/password_change.tsx b/ui/src/components/password_change.tsx
index 9445e8ed..f33e9af2 100644
--- a/ui/src/components/password_change.tsx
+++ b/ui/src/components/password_change.tsx
@@ -6,6 +6,7 @@ import {
   LoginResponse,
   PasswordChangeForm,
   WebSocketJsonResponse,
+  GetSiteResponse,
 } from '../interfaces';
 import { WebSocketService, UserService } from '../services';
 import { wsJsonToRes, capitalizeFirstLetter, toast } from '../utils';
@@ -40,18 +41,13 @@ export class PasswordChange extends Component<any, State> {
         err => console.error(err),
         () => console.log('complete')
       );
+    WebSocketService.Instance.getSite();
   }
 
   componentWillUnmount() {
     this.subscription.unsubscribe();
   }
 
-  componentDidMount() {
-    document.title = `${i18n.t('password_change')} - ${
-      WebSocketService.Instance.site.name
-    }`;
-  }
-
   render() {
     return (
       <div class="container">
@@ -138,14 +134,15 @@ export class PasswordChange extends Component<any, State> {
       this.state.loading = false;
       this.setState(this.state);
       return;
-    } else {
-      if (res.op == UserOperation.PasswordChange) {
-        let data = res.data as LoginResponse;
-        this.state = this.emptyState;
-        this.setState(this.state);
-        UserService.Instance.login(data);
-        this.props.history.push('/');
-      }
+    } else if (res.op == UserOperation.PasswordChange) {
+      let data = res.data as LoginResponse;
+      this.state = this.emptyState;
+      this.setState(this.state);
+      UserService.Instance.login(data);
+      this.props.history.push('/');
+    } else if (res.op == UserOperation.GetSite) {
+      let data = res.data as GetSiteResponse;
+      document.title = `${i18n.t('password_change')} - ${data.site.name}`;
     }
   }
 }
-- 
cgit v1.2.3

