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/modlog.tsx | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

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

diff --git a/ui/src/components/modlog.tsx b/ui/src/components/modlog.tsx
index 04628ebd..9a5131c9 100644
--- a/ui/src/components/modlog.tsx
+++ b/ui/src/components/modlog.tsx
@@ -16,6 +16,7 @@ import {
   ModAddCommunity,
   ModAdd,
   WebSocketJsonResponse,
+  GetSiteResponse,
 } from '../interfaces';
 import { WebSocketService } from '../services';
 import { wsJsonToRes, addTypeInfo, fetchLimit, toast } from '../utils';
@@ -64,16 +65,13 @@ export class Modlog extends Component<any, ModlogState> {
       );
 
     this.refetch();
+    WebSocketService.Instance.getSite();
   }
 
   componentWillUnmount() {
     this.subscription.unsubscribe();
   }
 
-  componentDidMount() {
-    document.title = `Modlog - ${WebSocketService.Instance.site.name}`;
-  }
-
   setCombined(res: GetModlogResponse) {
     let removed_posts = addTypeInfo(res.removed_posts, 'removed_posts');
     let locked_posts = addTypeInfo(res.locked_posts, 'locked_posts');
@@ -434,6 +432,9 @@ export class Modlog extends Component<any, ModlogState> {
       this.state.loading = false;
       window.scrollTo(0, 0);
       this.setCombined(data);
+    } else if (res.op == UserOperation.GetSite) {
+      let data = res.data as GetSiteResponse;
+      document.title = `Modlog - ${data.site.name}`;
     }
   }
 }
-- 
cgit v1.2.3

