remove user online status

This commit is contained in:
Anton SHEPILOV
2024-02-03 14:25:42 +01:00
parent b35687829c
commit ceee21b5eb
18 changed files with 4695 additions and 9195 deletions
@@ -20,7 +20,6 @@ export type UserPartsType = {
type PropsType = {
usersIds: string[];
keepMyself?: boolean;
displayOnline?: boolean;
max?: number;
size?: number;
};
@@ -48,7 +47,7 @@ export const getUserParts = (props: PropsType): UserPartsType => {
if (channelMembers?.length === 1) {
const avatarSrc = users[0]?.id ? (
<UserIcon user={users[0]} withStatus={props.displayOnline} size={avatarSize} />
<UserIcon user={users[0]} size={avatarSize} />
) : (
UserService.getThumbnail(users[0])
);
@@ -1,30 +0,0 @@
.online_user_status {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--grey-dark);
border: 1px solid var(--grey-background);
&.online {
background: var(--green);
}
&.offline {
background: var(--red);
}
&.small {
width: 6px;
height: 6px;
}
&.medium {
width: 8px;
height: 8px;
}
&.big {
width: 12px;
height: 12px;
}
}
@@ -1,47 +0,0 @@
// eslint-disable-next-line @typescript-eslint/no-use-before-define
import React, { Suspense } from 'react';
import classNames from 'classnames';
import { UserType } from '@features/users/types/user';
import { useOnlineUser } from '@features/users/hooks/use-online-user';
import './online-user-status.scss';
import { useUser } from '@features/users/hooks/use-user';
type PropsType = {
user: UserType;
size?: 'small' | 'medium' | 'big';
};
const WrappedUserStatus = ({ user: _user, size = 'medium' }: PropsType): JSX.Element => {
const user = useUser(_user.id || '');
const userOnlineStatus = useOnlineUser(_user.id as string);
//const lastSeen = userOnlineStatus?.lastSeen || user.last_seen;
const online =
(userOnlineStatus && userOnlineStatus.connected) ||
(!userOnlineStatus?.lastSeen &&
user?.is_connected &&
(user?.last_seen || 0) > Date.now() - 10 * 60 * 1000);
return (
<div
className={classNames('online_user_status ' + user?.last_seen + ' ', {
online: !!online,
offline: !online,
small: size === 'small',
medium: size === 'medium',
big: size === 'big',
})}
/>
);
};
const UserOnlineStatus = (props: PropsType): JSX.Element => {
return (
<Suspense fallback={<></>}>
<WrappedUserStatus {...props} />
</Suspense>
);
};
export default UserOnlineStatus;
@@ -2,7 +2,6 @@
import React, { Component } from 'react';
import UserService from '@features/users/services/current-user-service';
import UserOnlineStatus from '../online-user-status/online-user-status';
import './user.scss';
@@ -28,18 +27,6 @@ export default class User extends Component {
height: this.props.size,
}}
>
{this.props.withStatus && (
<UserOnlineStatus
user={user}
notifications_disabled={notifications_disabled}
size={
(this.props.small ? 'small' : undefined) ||
(this.props.medium ? 'medium' : undefined) ||
(this.props.big ? 'big' : undefined) ||
'medium'
}
/>
)}
</div>
);
}