You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/client/web/src/routes/Main/Content/Group/AckPanelItem.tsx

48 lines
1.2 KiB
TypeScript

import { GroupPanelItem } from '@/components/GroupPanelItem';
import React from 'react';
import {
GroupPanel,
useGroupTextPanelUnread,
useUserNotifyMute,
} from 'tailchat-shared';
import { useGroupPanelExtraBadge } from './utils';
interface GroupTextPanelItemProps {
groupId: string;
panel: GroupPanel;
icon: React.ReactNode;
}
/**
*
*/
export const GroupAckPanelItem: React.FC<GroupTextPanelItemProps> = React.memo(
(props) => {
const { groupId, panel } = props;
const panelId = panel.id;
const hasUnread = useGroupTextPanelUnread(panelId);
const extraBadge = useGroupPanelExtraBadge(
groupId,
panelId,
panel.pluginPanelName ?? ''
);
const { checkIsMuted } = useUserNotifyMute();
const isMuted = checkIsMuted(panelId, groupId);
return (
<GroupPanelItem
name={panel.name}
icon={props.icon}
to={`/main/group/${groupId}/${panel.id}`}
dimmed={isMuted}
badge={hasUnread}
badgeProps={{
status: isMuted ? 'default' : 'error',
}}
extraBadge={extraBadge}
/>
);
}
);
GroupAckPanelItem.displayName = 'GroupAckPanelItem';