mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
parent
c8da0a92ec
commit
e24f4a2d33
@ -81,6 +81,7 @@ pub struct GetSiteResponse {
|
|||||||
site: Option<SiteView>,
|
site: Option<SiteView>,
|
||||||
admins: Vec<UserView>,
|
admins: Vec<UserView>,
|
||||||
banned: Vec<UserView>,
|
banned: Vec<UserView>,
|
||||||
|
pub online: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@ -296,6 +297,7 @@ impl Perform<GetSiteResponse> for Oper<GetSite> {
|
|||||||
site: site_view,
|
site: site_view,
|
||||||
admins: admins,
|
admins: admins,
|
||||||
banned: banned,
|
banned: banned,
|
||||||
|
online: 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,6 +488,7 @@ impl Perform<GetSiteResponse> for Oper<TransferSite> {
|
|||||||
site: Some(site_view),
|
site: Some(site_view),
|
||||||
admins: admins,
|
admins: admins,
|
||||||
banned: banned,
|
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)?)
|
Ok(serde_json::to_string(&res)?)
|
||||||
}
|
}
|
||||||
UserOperation::GetSite => {
|
UserOperation::GetSite => {
|
||||||
|
let online: usize = chat.sessions.len();
|
||||||
let get_site: GetSite = serde_json::from_str(data)?;
|
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)?)
|
Ok(serde_json::to_string(&res)?)
|
||||||
}
|
}
|
||||||
UserOperation::Search => {
|
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: [],
|
admins: [],
|
||||||
banned: [],
|
banned: [],
|
||||||
|
online: null,
|
||||||
},
|
},
|
||||||
showEditSite: false,
|
showEditSite: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
@ -215,6 +216,9 @@ export class Main extends Component<any, MainState> {
|
|||||||
</ul>
|
</ul>
|
||||||
}
|
}
|
||||||
<ul class="my-2 list-inline">
|
<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">
|
<li className="list-inline-item badge badge-secondary">
|
||||||
<T i18nKey="number_of_users" interpolation={{count: this.state.site.site.number_of_users}}>#</T>
|
<T i18nKey="number_of_users" interpolation={{count: this.state.site.site.number_of_users}}>#</T>
|
||||||
</li>
|
</li>
|
||||||
@ -420,6 +424,7 @@ export class Main extends Component<any, MainState> {
|
|||||||
this.state.site.admins = res.admins;
|
this.state.site.admins = res.admins;
|
||||||
this.state.site.site = res.site;
|
this.state.site.site = res.site;
|
||||||
this.state.site.banned = res.banned;
|
this.state.site.banned = res.banned;
|
||||||
|
this.state.site.online = res.online;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
document.title = `${WebSocketService.Instance.site.name}`;
|
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;
|
site: Site;
|
||||||
admins: Array<UserView>;
|
admins: Array<UserView>;
|
||||||
banned: 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_users:'{{count}} Users',
|
||||||
number_of_subscribers:'{{count}} Subscribers',
|
number_of_subscribers:'{{count}} Subscribers',
|
||||||
number_of_points:'{{count}} Points',
|
number_of_points:'{{count}} Points',
|
||||||
|
number_online:'{{count}} Users Online',
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
category: 'Category',
|
category: 'Category',
|
||||||
|
Loading…
Reference in New Issue
Block a user