2022-03-25 20:05:49 +00:00
|
|
|
import React from 'react';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-05-13 15:01:34 +00:00
|
|
|
import { TUserStatus } from '../../definitions';
|
2021-09-13 20:41:05 +00:00
|
|
|
import Status from './Status';
|
2022-03-25 20:05:49 +00:00
|
|
|
import { IStatus } from './definition';
|
2022-05-13 15:01:34 +00:00
|
|
|
import { useAppSelector } from '../../lib/hooks';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-03-25 20:05:49 +00:00
|
|
|
const StatusContainer = ({ id, style, size = 32, ...props }: Omit<IStatus, 'status'>): React.ReactElement => {
|
2023-02-14 13:47:56 +00:00
|
|
|
const status = useAppSelector(state => {
|
|
|
|
if (state.settings.Presence_broadcast_disabled) {
|
|
|
|
return 'disabled';
|
|
|
|
}
|
|
|
|
if (state.meteor.connected) {
|
|
|
|
return state.activeUsers[id] && state.activeUsers[id].status;
|
|
|
|
}
|
|
|
|
return 'loading';
|
|
|
|
}) as TUserStatus;
|
2022-03-25 20:05:49 +00:00
|
|
|
return <Status size={size} style={style} status={status} {...props} />;
|
|
|
|
};
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-03-25 20:05:49 +00:00
|
|
|
export default StatusContainer;
|