mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 16:02:12 +00:00
parent
0b75d46453
commit
909628bc34
|
@ -81,6 +81,7 @@ pub struct GetSiteResponse {
|
|||
site: Option<SiteView>,
|
||||
admins: Vec<UserView>,
|
||||
banned: Vec<UserView>,
|
||||
pub online: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
@ -296,6 +297,7 @@ impl Perform<GetSiteResponse> for Oper<GetSite> {
|
|||
site: site_view,
|
||||
admins: admins,
|
||||
banned: banned,
|
||||
online: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -486,6 +488,7 @@ impl Perform<GetSiteResponse> for Oper<TransferSite> {
|
|||
site: Some(site_view),
|
||||
admins: admins,
|
||||
banned: banned,
|
||||
online: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -492,8 +492,10 @@ fn parse_json_message(chat: &mut ChatServer, msg: StandardMessage) -> Result<Str
|
|||
Ok(serde_json::to_string(&res)?)
|
||||
}
|
||||
UserOperation::GetSite => {
|
||||
let online: usize = chat.sessions.len();
|
||||
let get_site: GetSite = serde_json::from_str(data)?;
|
||||
let res = Oper::new(user_operation, get_site).perform()?;
|
||||
let mut res = Oper::new(user_operation, get_site).perform()?;
|
||||
res.online = online;
|
||||
Ok(serde_json::to_string(&res)?)
|
||||
}
|
||||
UserOperation::Search => {
|
||||
|
|
5
ui/src/components/main.tsx
vendored
5
ui/src/components/main.tsx
vendored
|
@ -43,6 +43,7 @@ export class Main extends Component<any, MainState> {
|
|||
},
|
||||
admins: [],
|
||||
banned: [],
|
||||
online: null,
|
||||
},
|
||||
showEditSite: false,
|
||||
loading: true,
|
||||
|
@ -215,6 +216,9 @@ export class Main extends Component<any, MainState> {
|
|||
</ul>
|
||||
}
|
||||
<ul class="my-2 list-inline">
|
||||
<li className="list-inline-item badge badge-secondary">
|
||||
<T i18nKey="number_online" interpolation={{count: this.state.site.online}}>#</T>
|
||||
</li>
|
||||
<li className="list-inline-item badge badge-secondary">
|
||||
<T i18nKey="number_of_users" interpolation={{count: this.state.site.site.number_of_users}}>#</T>
|
||||
</li>
|
||||
|
@ -420,6 +424,7 @@ export class Main extends Component<any, MainState> {
|
|||
this.state.site.admins = res.admins;
|
||||
this.state.site.site = res.site;
|
||||
this.state.site.banned = res.banned;
|
||||
this.state.site.online = res.online;
|
||||
this.setState(this.state);
|
||||
document.title = `${WebSocketService.Instance.site.name}`;
|
||||
|
||||
|
|
1
ui/src/interfaces.ts
vendored
1
ui/src/interfaces.ts
vendored
|
@ -546,6 +546,7 @@ export interface GetSiteResponse {
|
|||
site: Site;
|
||||
admins: Array<UserView>;
|
||||
banned: Array<UserView>;
|
||||
online: number;
|
||||
}
|
||||
|
||||
|
||||
|
|
1
ui/src/translations/en.ts
vendored
1
ui/src/translations/en.ts
vendored
|
@ -70,6 +70,7 @@ export const en = {
|
|||
number_of_users:'{{count}} Users',
|
||||
number_of_subscribers:'{{count}} Subscribers',
|
||||
number_of_points:'{{count}} Points',
|
||||
number_online:'{{count}} Users Online',
|
||||
name: 'Name',
|
||||
title: 'Title',
|
||||
category: 'Category',
|
||||
|
|
Loading…
Reference in a new issue