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';
expanded: boolean;
expandUserDropdown: boolean;
unreadCount: number;
+ siteName: string;
}
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) {
(err) => console.error(err),
() => console.log('complete')
);
+
+ WebSocketService.Instance.getSite();
}
render() {
}
// 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>
} 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);
+ }
}
}