1 import { Component } from 'inferno';
2 import { Link } from 'inferno-router';
3 import { i18n } from '../i18next';
4 import { Subscription } from 'rxjs';
5 import { retryWhen, delay, take } from 'rxjs/operators';
6 import { WebSocketService } from '../services';
7 import { repoUrl, wsJsonToRes } from '../utils';
10 WebSocketJsonResponse,
12 } from '../interfaces';
14 interface FooterState {
18 export class Footer extends Component<any, FooterState> {
19 private wsSub: Subscription;
20 emptyState: FooterState = {
23 constructor(props: any, context: any) {
24 super(props, context);
26 this.state = this.emptyState;
28 this.wsSub = WebSocketService.Instance.subject
29 .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
31 msg => this.parseMessage(msg),
32 err => console.error(err),
33 () => console.log('complete')
37 componentWillUnmount() {
38 this.wsSub.unsubscribe();
43 <nav class="container navbar navbar-expand-md navbar-light navbar-bg p-0 px-3 mt-2">
44 <div className="navbar-collapse">
45 <ul class="navbar-nav ml-auto">
47 <span class="navbar-text">{this.state.version}</span>
50 <Link class="nav-link" to="/modlog">
55 <a class="nav-link" href={'/docs/index.html'}>
60 <Link class="nav-link" to="/sponsors">
65 <a class="nav-link" href={repoUrl}>
74 parseMessage(msg: WebSocketJsonResponse) {
75 let res = wsJsonToRes(msg);
77 if (res.op == UserOperation.GetSite) {
78 let data = res.data as GetSiteResponse;
79 this.setState({ version: data.version });