diff options
author | Dessalines <tyhou13@gmx.com> | 2019-04-30 08:19:00 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-04-30 08:19:00 -0700 |
commit | 675cf6165488b0a68fe06696fda076c60ff96a76 (patch) | |
tree | b6bc68af1f9f6ea61e2c42985f7916a8a463644c /ui/src/components/navbar.tsx | |
parent | b04d4f03c55cbffefc16757b44207d962e34c8eb (diff) |
Custom site name.
- Fixes #113
Diffstat (limited to 'ui/src/components/navbar.tsx')
-rw-r--r-- | ui/src/components/navbar.tsx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index ee19e5c5..6861461c 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -3,7 +3,7 @@ import { Link } from 'inferno-router'; import { Subscription } from "rxjs"; import { retryWhen, delay, take } from 'rxjs/operators'; import { WebSocketService, UserService } from '../services'; -import { UserOperation, GetRepliesForm, GetRepliesResponse, SortType } from '../interfaces'; +import { UserOperation, GetRepliesForm, GetRepliesResponse, SortType, GetSiteResponse } from '../interfaces'; import { msgOp } from '../utils'; import { version } from '../version'; @@ -12,6 +12,7 @@ interface NavbarState { expanded: boolean; expandUserDropdown: boolean; unreadCount: number; + siteName: string; } export class Navbar extends Component<any, NavbarState> { @@ -21,7 +22,8 @@ export class Navbar extends Component<any, NavbarState> { isLoggedIn: (UserService.Instance.user !== undefined), unreadCount: 0, expanded: false, - expandUserDropdown: false + expandUserDropdown: false, + siteName: undefined } constructor(props: any, context: any) { @@ -45,6 +47,8 @@ export class Navbar extends Component<any, NavbarState> { (err) => console.error(err), () => console.log('complete') ); + + WebSocketService.Instance.getSite(); } render() { @@ -59,13 +63,12 @@ export class Navbar extends Component<any, NavbarState> { } // TODO class active corresponding to current page - // TODO toggle css collapse navbar() { return ( <nav class="container navbar navbar-expand-md navbar-light navbar-bg p-0 px-3"> <Link title={version} class="navbar-brand" to="/"> <svg class="icon mr-2 mouse-icon"><use xlinkHref="#icon-mouse"></use></svg> - Lemmy + {this.state.siteName} </Link> <button class="navbar-toggler" type="button" onClick={linkEvent(this, this.expandNavbar)}> <span class="navbar-toggler-icon"></span> @@ -145,6 +148,14 @@ export class Navbar extends Component<any, NavbarState> { } else if (op == UserOperation.GetReplies) { let res: GetRepliesResponse = msg; this.sendRepliesCount(res); + } else if (op == UserOperation.GetSite) { + let res: GetSiteResponse = msg; + + if (res.site) { + this.state.siteName = res.site.name; + WebSocketService.Instance.site = res.site; + this.setState(this.state); + } } } |