Change subscribers to users. Fixes #195

This commit is contained in:
Dessalines 2021-02-23 09:58:31 -05:00
parent ee77f700b3
commit e33102bca3

View file

@ -1,6 +1,6 @@
import { Component, linkEvent } from 'inferno'; import { Component, linkEvent } from "inferno";
import { Link } from 'inferno-router'; import { Link } from "inferno-router";
import { Subscription } from 'rxjs'; import { Subscription } from "rxjs";
import { import {
UserOperation, UserOperation,
CommunityFollowerView, CommunityFollowerView,
@ -22,19 +22,19 @@ import {
CommentResponse, CommentResponse,
AddAdminResponse, AddAdminResponse,
BanUserResponse, BanUserResponse,
} from 'lemmy-js-client'; } from "lemmy-js-client";
import { DataType, InitialFetchRequest } from '../interfaces'; import { DataType, InitialFetchRequest } from "../interfaces";
import { WebSocketService, UserService } from '../services'; import { WebSocketService, UserService } from "../services";
import { PostListings } from './post-listings'; import { PostListings } from "./post-listings";
import { CommentNodes } from './comment-nodes'; import { CommentNodes } from "./comment-nodes";
import { SortSelect } from './sort-select'; import { SortSelect } from "./sort-select";
import { ListingTypeSelect } from './listing-type-select'; import { ListingTypeSelect } from "./listing-type-select";
import { DataTypeSelect } from './data-type-select'; import { DataTypeSelect } from "./data-type-select";
import { SiteForm } from './site-form'; import { SiteForm } from "./site-form";
import { UserListing } from './user-listing'; import { UserListing } from "./user-listing";
import { CommunityLink } from './community-link'; import { CommunityLink } from "./community-link";
import { BannerIconHeader } from './banner-icon-header'; import { BannerIconHeader } from "./banner-icon-header";
import { Icon, Spinner } from './icon'; import { Icon, Spinner } from "./icon";
import { import {
wsJsonToRes, wsJsonToRes,
mdToHtml, mdToHtml,
@ -60,10 +60,10 @@ import {
authField, authField,
saveScrollPosition, saveScrollPosition,
restoreScrollPosition, restoreScrollPosition,
} from '../utils'; } from "../utils";
import { i18n } from '../i18next'; import { i18n } from "../i18next";
import { T } from 'inferno-i18next'; import { T } from "inferno-i18next";
import { HtmlTags } from './html-tags'; import { HtmlTags } from "./html-tags";
interface MainState { interface MainState {
subscribedCommunities: CommunityFollowerView[]; subscribedCommunities: CommunityFollowerView[];
@ -164,7 +164,7 @@ export class Main extends Component<any, MainState> {
componentDidMount() { componentDidMount() {
// This means it hasn't been set up yet // This means it hasn't been set up yet
if (!this.state.siteRes.site_view) { if (!this.state.siteRes.site_view) {
this.context.router.history.push('/setup'); this.context.router.history.push("/setup");
} }
WebSocketService.Instance.send(wsClient.communityJoin({ community_id: 0 })); WebSocketService.Instance.send(wsClient.communityJoin({ community_id: 0 }));
@ -186,7 +186,7 @@ export class Main extends Component<any, MainState> {
} }
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] { static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
let pathSplit = req.path.split('/'); let pathSplit = req.path.split("/");
let dataType: DataType = pathSplit[3] let dataType: DataType = pathSplit[3]
? DataType[pathSplit[3]] ? DataType[pathSplit[3]]
: DataType.Post; : DataType.Post;
@ -259,7 +259,7 @@ export class Main extends Component<any, MainState> {
return `${ return `${
this.state.siteRes.site_view this.state.siteRes.site_view
? this.state.siteRes.site_view.site.name ? this.state.siteRes.site_view.site.name
: 'Lemmy' : "Lemmy"
}`; }`;
} }
@ -313,7 +313,7 @@ export class Main extends Component<any, MainState> {
createCommunityButton() { createCommunityButton() {
return ( return (
<Link className="btn btn-secondary btn-block" to="/create_community"> <Link className="btn btn-secondary btn-block" to="/create_community">
{i18n.t('create_a_community')} {i18n.t("create_a_community")}
</Link> </Link>
); );
} }
@ -410,7 +410,7 @@ export class Main extends Component<any, MainState> {
admins() { admins() {
return ( return (
<ul class="mt-1 list-inline small mb-0"> <ul class="mt-1 list-inline small mb-0">
<li class="list-inline-item">{i18n.t('admins')}:</li> <li class="list-inline-item">{i18n.t("admins")}:</li>
{this.state.siteRes.admins.map(av => ( {this.state.siteRes.admins.map(av => (
<li class="list-inline-item"> <li class="list-inline-item">
<UserListing user={av.user} /> <UserListing user={av.user} />
@ -425,77 +425,77 @@ export class Main extends Component<any, MainState> {
return ( return (
<ul class="my-2 list-inline"> <ul class="my-2 list-inline">
<li className="list-inline-item badge badge-secondary"> <li className="list-inline-item badge badge-secondary">
{i18n.t('number_online', { count: this.state.siteRes.online })} {i18n.t("number_online", { count: this.state.siteRes.online })}
</li> </li>
<li <li
className="list-inline-item badge badge-secondary pointer" className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t('number_of_users', { data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_day, count: counts.users_active_day,
})} ${i18n.t('active_in_the_last')} ${i18n.t('day')}`} })} ${i18n.t("active_in_the_last")} ${i18n.t("day")}`}
> >
{i18n.t('number_of_users', { {i18n.t("number_of_users", {
count: counts.users_active_day, count: counts.users_active_day,
})}{' '} })}{" "}
/ {i18n.t('day')} / {i18n.t("day")}
</li> </li>
<li <li
className="list-inline-item badge badge-secondary pointer" className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t('number_of_users', { data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_week, count: counts.users_active_week,
})} ${i18n.t('active_in_the_last')} ${i18n.t('week')}`} })} ${i18n.t("active_in_the_last")} ${i18n.t("week")}`}
> >
{i18n.t('number_of_users', { {i18n.t("number_of_users", {
count: counts.users_active_week, count: counts.users_active_week,
})}{' '} })}{" "}
/ {i18n.t('week')} / {i18n.t("week")}
</li> </li>
<li <li
className="list-inline-item badge badge-secondary pointer" className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t('number_of_users', { data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_month, count: counts.users_active_month,
})} ${i18n.t('active_in_the_last')} ${i18n.t('month')}`} })} ${i18n.t("active_in_the_last")} ${i18n.t("month")}`}
> >
{i18n.t('number_of_users', { {i18n.t("number_of_users", {
count: counts.users_active_month, count: counts.users_active_month,
})}{' '} })}{" "}
/ {i18n.t('month')} / {i18n.t("month")}
</li> </li>
<li <li
className="list-inline-item badge badge-secondary pointer" className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t('number_of_users', { data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_half_year, count: counts.users_active_half_year,
})} ${i18n.t('active_in_the_last')} ${i18n.t('number_of_months', { })} ${i18n.t("active_in_the_last")} ${i18n.t("number_of_months", {
count: 6, count: 6,
})}`} })}`}
> >
{i18n.t('number_of_users', { {i18n.t("number_of_users", {
count: counts.users_active_half_year, count: counts.users_active_half_year,
})}{' '} })}{" "}
/ {i18n.t('number_of_months', { count: 6 })} / {i18n.t("number_of_months", { count: 6 })}
</li> </li>
<li className="list-inline-item badge badge-secondary"> <li className="list-inline-item badge badge-secondary">
{i18n.t('number_of_subscribers', { {i18n.t("number_of_users", {
count: counts.users, count: counts.users,
})} })}
</li> </li>
<li className="list-inline-item badge badge-secondary"> <li className="list-inline-item badge badge-secondary">
{i18n.t('number_of_communities', { {i18n.t("number_of_communities", {
count: counts.communities, count: counts.communities,
})} })}
</li> </li>
<li className="list-inline-item badge badge-secondary"> <li className="list-inline-item badge badge-secondary">
{i18n.t('number_of_posts', { {i18n.t("number_of_posts", {
count: counts.posts, count: counts.posts,
})} })}
</li> </li>
<li className="list-inline-item badge badge-secondary"> <li className="list-inline-item badge badge-secondary">
{i18n.t('number_of_comments', { {i18n.t("number_of_comments", {
count: counts.comments, count: counts.comments,
})} })}
</li> </li>
<li className="list-inline-item"> <li className="list-inline-item">
<Link className="badge badge-secondary" to="/modlog"> <Link className="badge badge-secondary" to="/modlog">
{i18n.t('modlog')} {i18n.t("modlog")}
</Link> </Link>
</li> </li>
</ul> </ul>
@ -511,8 +511,8 @@ export class Main extends Component<any, MainState> {
class="pointer" class="pointer"
role="button" role="button"
onClick={linkEvent(this, this.handleEditClick)} onClick={linkEvent(this, this.handleEditClick)}
aria-label={i18n.t('edit')} aria-label={i18n.t("edit")}
data-tippy-content={i18n.t('edit')} data-tippy-content={i18n.t("edit")}
> >
<Icon icon="edit" classes="icon-inline" /> <Icon icon="edit" classes="icon-inline" />
</span> </span>
@ -631,7 +631,7 @@ export class Main extends Component<any, MainState> {
class="btn btn-secondary mr-1" class="btn btn-secondary mr-1"
onClick={linkEvent(this, this.prevPage)} onClick={linkEvent(this, this.prevPage)}
> >
{i18n.t('prev')} {i18n.t("prev")}
</button> </button>
)} )}
{this.state.posts.length > 0 && ( {this.state.posts.length > 0 && (
@ -639,7 +639,7 @@ export class Main extends Component<any, MainState> {
class="btn btn-secondary" class="btn btn-secondary"
onClick={linkEvent(this, this.nextPage)} onClick={linkEvent(this, this.nextPage)}
> >
{i18n.t('next')} {i18n.t("next")}
</button> </button>
)} )}
</div> </div>
@ -719,7 +719,7 @@ export class Main extends Component<any, MainState> {
parseMessage(msg: any) { parseMessage(msg: any) {
let op = wsUserOp(msg); let op = wsUserOp(msg);
if (msg.error) { if (msg.error) {
toast(i18n.t(msg.error), 'danger'); toast(i18n.t(msg.error), "danger");
return; return;
} else if (msg.reconnect) { } else if (msg.reconnect) {
WebSocketService.Instance.send( WebSocketService.Instance.send(
@ -739,7 +739,7 @@ export class Main extends Component<any, MainState> {
this.state.siteRes.site_view = data.site_view; this.state.siteRes.site_view = data.site_view;
this.state.showEditSite = false; this.state.showEditSite = false;
this.setState(this.state); this.setState(this.state);
toast(i18n.t('site_saved')); toast(i18n.t("site_saved"));
} else if (op == UserOperation.GetPosts) { } else if (op == UserOperation.GetPosts) {
let data = wsJsonToRes<GetPostsResponse>(msg).data; let data = wsJsonToRes<GetPostsResponse>(msg).data;
this.state.posts = data.posts; this.state.posts = data.posts;