summaryrefslogtreecommitdiffstats
path: root/ui/src/components/sponsors.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components/sponsors.tsx')
-rw-r--r--ui/src/components/sponsors.tsx40
1 files changed, 36 insertions, 4 deletions
diff --git a/ui/src/components/sponsors.tsx b/ui/src/components/sponsors.tsx
index 4561bc30..6ff9b2ca 100644
--- a/ui/src/components/sponsors.tsx
+++ b/ui/src/components/sponsors.tsx
@@ -1,8 +1,15 @@
import { Component } from 'inferno';
+import { Subscription } from 'rxjs';
+import { retryWhen, delay, take } from 'rxjs/operators';
import { WebSocketService } from '../services';
+import {
+ GetSiteResponse,
+ WebSocketJsonResponse,
+ UserOperation,
+} from '../interfaces';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
-import { repoUrl } from '../utils';
+import { repoUrl, wsJsonToRes, toast } from '../utils';
interface SilverUser {
name: string;
@@ -10,6 +17,8 @@ interface SilverUser {
}
let general = [
+ 'ybaumy',
+ 'dude in phx',
'twilight loki',
'Andrew Plaza',
'Jonathan Cremin',
@@ -31,17 +40,28 @@ let silver: Array<SilverUser> = [
// let latinum = [];
export class Sponsors extends Component<any, any> {
+ private subscription: Subscription;
constructor(props: any, context: any) {
super(props, context);
+ this.subscription = WebSocketService.Instance.subject
+ .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
+ .subscribe(
+ msg => this.parseMessage(msg),
+ err => console.error(err),
+ () => console.log('complete')
+ );
+
+ WebSocketService.Instance.getSite();
}
componentDidMount() {
- document.title = `${i18n.t('sponsors')} - ${
- WebSocketService.Instance.site.name
- }`;
window.scrollTo(0, 0);
}
+ componentWillUnmount() {
+ this.subscription.unsubscribe();
+ }
+
render() {
return (
<div class="container text-center">
@@ -151,4 +171,16 @@ export class Sponsors extends Component<any, any> {
</div>
);
}
+
+ parseMessage(msg: WebSocketJsonResponse) {
+ console.log(msg);
+ let res = wsJsonToRes(msg);
+ if (msg.error) {
+ toast(i18n.t(msg.error), 'danger');
+ return;
+ } else if (res.op == UserOperation.GetSite) {
+ let data = res.data as GetSiteResponse;
+ document.title = `${i18n.t('sponsors')} - ${data.site.name}`;
+ }
+ }
}