TelegramPWA/src/components/left/main/AvatarBadge.tsx
2023-04-26 21:18:42 +04:00

53 lines
1.2 KiB
TypeScript

import type { FC } from '../../../lib/teact/teact';
import React, { memo } from '../../../lib/teact/teact';
import { withGlobal } from '../../../global';
import type { ApiChat } from '../../../api/types';
import { selectIsChatMuted } from '../../../global/helpers';
import {
selectChat,
selectNotifySettings,
selectNotifyExceptions,
selectIsForumPanelOpen,
} from '../../../global/selectors';
import ChatBadge from './ChatBadge';
type OwnProps = {
chatId: string;
};
type StateProps = {
chat?: ApiChat;
isMuted?: boolean;
isForumPanelActive?: boolean;
};
const AvatarBadge: FC<OwnProps & StateProps> = ({
chat,
isMuted,
isForumPanelActive,
}) => {
return chat && (
<div className="avatar-badge-wrapper">
<ChatBadge chat={chat} isMuted={isMuted} shouldShowOnlyMostImportant forceHidden={!isForumPanelActive} />
</div>
);
};
export default memo(withGlobal<OwnProps>(
(global, { chatId }): StateProps => {
const chat = selectChat(global, chatId);
if (!chat) {
return {};
}
return {
chat,
isMuted: selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)),
isForumPanelActive: selectIsForumPanelOpen(global),
};
},
)(AvatarBadge));