import { Component } from 'inferno';
+import { Helmet } from 'inferno-helmet';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import { WebSocketService } from '../services';
import {
GetSiteResponse,
+ Site,
WebSocketJsonResponse,
UserOperation,
-} from '../interfaces';
+} from 'lemmy-js-client';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
import { repoUrl, wsJsonToRes, toast } from '../utils';
}
let general = [
+ 'Brendan',
+ 'mexicanhalloween',
'William Moore',
'Rachel Schmitz',
'comradeda',
// let gold = [];
// let latinum = [];
-export class Sponsors extends Component<any, any> {
+interface SponsorsState {
+ site: Site;
+}
+
+export class Sponsors extends Component<any, SponsorsState> {
private subscription: Subscription;
+ private emptyState: SponsorsState = {
+ site: undefined,
+ };
constructor(props: any, context: any) {
super(props, context);
+ this.state = this.emptyState;
this.subscription = WebSocketService.Instance.subject
.pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
.subscribe(
this.subscription.unsubscribe();
}
+ get documentTitle(): string {
+ if (this.state.site) {
+ return `${i18n.t('sponsors')} - ${this.state.site.name}`;
+ } else {
+ return 'Lemmy';
+ }
+ }
+
render() {
return (
<div class="container text-center">
+ <Helmet title={this.documentTitle} />
{this.topMessage()}
<hr />
{this.sponsors()}
return;
} else if (res.op == UserOperation.GetSite) {
let data = res.data as GetSiteResponse;
- document.title = `${i18n.t('sponsors')} - ${data.site.name}`;
+ this.state.site = data.site;
+ this.setState(this.state);
}
}
}