import { Component, linkEvent } from 'inferno';
+import { Helmet } from 'inferno-helmet';
import { Link } from 'inferno-router';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
ModBan,
ModAddCommunity,
ModAdd,
-} from '../interfaces';
+ WebSocketJsonResponse,
+ GetSiteResponse,
+ Site,
+} from 'lemmy-js-client';
import { WebSocketService } from '../services';
import { wsJsonToRes, addTypeInfo, fetchLimit, toast } from '../utils';
import { MomentTime } from './moment-time';
communityId?: number;
communityName?: string;
page: number;
+ site: Site;
loading: boolean;
}
combined: [],
page: 1,
loading: true,
+ site: undefined,
};
constructor(props: any, context: any) {
);
this.refetch();
+ WebSocketService.Instance.getSite();
}
componentWillUnmount() {
this.subscription.unsubscribe();
}
- componentDidMount() {
- document.title = `Modlog - ${WebSocketService.Instance.site.name}`;
- }
-
setCombined(res: GetModlogResponse) {
let removed_posts = addTypeInfo(res.removed_posts, 'removed_posts');
let locked_posts = addTypeInfo(res.locked_posts, 'locked_posts');
);
}
+ get documentTitle(): string {
+ if (this.state.site) {
+ return `Modlog - ${this.state.site.name}`;
+ } else {
+ return 'Lemmy';
+ }
+ }
+
render() {
return (
<div class="container">
+ <Helmet title={this.documentTitle} />
{this.state.loading ? (
- <h5 class="text-center">
+ <h5 class="">
<svg class="icon icon-spinner spin">
<use xlinkHref="#icon-spinner"></use>
</svg>
<h5>
{this.state.communityName && (
<Link
- className="text-white"
+ className="text-body"
to={`/c/${this.state.communityName}`}
>
/c/{this.state.communityName}{' '}
</Link>
)}
- <span>{ i18n.t('modlog') }</span>
+ <span>{i18n.t('modlog')}</span>
</h5>
<div class="table-responsive">
<table id="modlog_table" class="table table-sm table-hover">
<thead class="pointer">
<tr>
- <th> { i18n.t('time')}</th>
- <th>{ i18n.t('mod')}</th>
- <th>{ i18n.t('action')}</th>
+ <th> {i18n.t('time')}</th>
+ <th>{i18n.t('mod')}</th>
+ <th>{i18n.t('action')}</th>
</tr>
</thead>
{this.combined()}
<div class="mt-2">
{this.state.page > 1 && (
<button
- class="btn btn-sm btn-secondary mr-1"
+ class="btn btn-secondary mr-1"
onClick={linkEvent(this, this.prevPage)}
>
- { i18n.t('prev') }
+ {i18n.t('prev')}
</button>
)}
<button
- class="btn btn-sm btn-secondary"
+ class="btn btn-secondary"
onClick={linkEvent(this, this.nextPage)}
>
- { i18n.t('next') }
+ {i18n.t('next')}
</button>
</div>
);
this.state.loading = false;
window.scrollTo(0, 0);
this.setCombined(data);
+ } else if (res.op == UserOperation.GetSite) {
+ let data = res.data as GetSiteResponse;
+ this.state.site = data.site;
+ this.setState(this.state);
}
}
}