mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-24 10:07:18 +00:00
Merge pull request #1075 from LemmyNet/fix_online_counts
Fixing online counts. Fixes #664
This commit is contained in:
commit
4981eb38fb
|
@ -4,7 +4,7 @@ use crate::{
|
|||
apub::ActorType,
|
||||
blocking,
|
||||
websocket::{
|
||||
server::{JoinCommunityRoom, SendCommunityRoomMessage},
|
||||
server::{GetCommunityUsersOnline, JoinCommunityRoom, SendCommunityRoomMessage},
|
||||
UserOperation,
|
||||
WebsocketInfo,
|
||||
},
|
||||
|
@ -205,13 +205,10 @@ impl Perform for GetCommunity {
|
|||
id,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO
|
||||
1
|
||||
// let fut = async {
|
||||
// ws.chatserver.send(GetCommunityUsersOnline {community_id}).await.unwrap()
|
||||
// };
|
||||
// Runtime::new().unwrap().block_on(fut)
|
||||
ws.chatserver
|
||||
.send(GetCommunityUsersOnline { community_id })
|
||||
.await
|
||||
.unwrap_or(1)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
blocking,
|
||||
fetch_iframely_and_pictrs_data,
|
||||
websocket::{
|
||||
server::{JoinCommunityRoom, JoinPostRoom, SendPost},
|
||||
server::{GetPostUsersOnline, JoinCommunityRoom, JoinPostRoom, SendPost},
|
||||
UserOperation,
|
||||
WebsocketInfo,
|
||||
},
|
||||
|
@ -308,13 +308,10 @@ impl Perform for GetPost {
|
|||
id,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO
|
||||
1
|
||||
// let fut = async {
|
||||
// ws.chatserver.send(GetPostUsersOnline {post_id: data.id}).await.unwrap()
|
||||
// };
|
||||
// Runtime::new().unwrap().block_on(fut)
|
||||
ws.chatserver
|
||||
.send(GetPostUsersOnline { post_id: data.id })
|
||||
.await
|
||||
.unwrap_or(1)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
|
|
@ -12,7 +12,11 @@ use crate::{
|
|||
apub::fetcher::search_by_apub_id,
|
||||
blocking,
|
||||
version,
|
||||
websocket::{server::SendAllMessage, UserOperation, WebsocketInfo},
|
||||
websocket::{
|
||||
server::{GetUsersOnline, SendAllMessage},
|
||||
UserOperation,
|
||||
WebsocketInfo,
|
||||
},
|
||||
DbPool,
|
||||
LemmyError,
|
||||
};
|
||||
|
@ -414,13 +418,8 @@ impl Perform for GetSite {
|
|||
|
||||
let banned = blocking(pool, move |conn| UserView::banned(conn)).await??;
|
||||
|
||||
let online = if let Some(_ws) = websocket_info {
|
||||
// TODO
|
||||
1
|
||||
// let fut = async {
|
||||
// ws.chatserver.send(GetUsersOnline).await.unwrap()
|
||||
// };
|
||||
// Runtime::new().unwrap().block_on(fut)
|
||||
let online = if let Some(ws) = websocket_info {
|
||||
ws.chatserver.send(GetUsersOnline).await.unwrap_or(1)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
|
8
ui/src/components/main.tsx
vendored
8
ui/src/components/main.tsx
vendored
|
@ -385,11 +385,9 @@ export class Main extends Component<any, MainState> {
|
|||
badges() {
|
||||
return (
|
||||
<ul class="my-2 list-inline">
|
||||
{/*
|
||||
<li className="list-inline-item badge badge-light">
|
||||
{i18n.t('number_online', { count: this.state.siteRes.online })}
|
||||
</li>
|
||||
*/}
|
||||
<li className="list-inline-item badge badge-light">
|
||||
{i18n.t('number_online', { count: this.state.siteRes.online })}
|
||||
</li>
|
||||
<li className="list-inline-item badge badge-light">
|
||||
{i18n.t('number_of_users', {
|
||||
count: this.state.siteRes.site.number_of_users,
|
||||
|
|
8
ui/src/components/sidebar.tsx
vendored
8
ui/src/components/sidebar.tsx
vendored
|
@ -125,11 +125,9 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
|||
let community = this.props.community;
|
||||
return (
|
||||
<ul class="my-1 list-inline">
|
||||
{/*
|
||||
<li className="list-inline-item badge badge-light">
|
||||
{i18n.t('number_online', { count: this.props.online })}
|
||||
</li>
|
||||
*/}
|
||||
<li className="list-inline-item badge badge-light">
|
||||
{i18n.t('number_online', { count: this.props.online })}
|
||||
</li>
|
||||
<li className="list-inline-item badge badge-light">
|
||||
{i18n.t('number_of_subscribers', {
|
||||
count: community.number_of_subscribers,
|
||||
|
|
Loading…
Reference in a new issue