|
|
@ -1,6 +1,6 @@
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import { CommonSidebarWrapper } from '@/components/CommonSidebarWrapper';
|
|
|
|
import { CommonSidebarWrapper } from '@/components/CommonSidebarWrapper';
|
|
|
|
import { isValidStr, model, t, useInboxList } from 'tailchat-shared';
|
|
|
|
import { InboxItem, isValidStr, model, t, useInboxList } from 'tailchat-shared';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
import _orderBy from 'lodash/orderBy';
|
|
|
|
import _orderBy from 'lodash/orderBy';
|
|
|
|
import { GroupName } from '@/components/GroupName';
|
|
|
|
import { GroupName } from '@/components/GroupName';
|
|
|
@ -8,6 +8,7 @@ import { ConverseName } from '@/components/ConverseName';
|
|
|
|
import { getMessageRender } from '@/plugin/common';
|
|
|
|
import { getMessageRender } from '@/plugin/common';
|
|
|
|
import { useLocation } from 'react-router';
|
|
|
|
import { useLocation } from 'react-router';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
|
|
|
import { PillTabPane, PillTabs } from '@/components/PillTabs';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 收件箱侧边栏组件
|
|
|
|
* 收件箱侧边栏组件
|
|
|
@ -16,10 +17,7 @@ export const InboxSidebar: React.FC = React.memo(() => {
|
|
|
|
const inbox = useInboxList();
|
|
|
|
const inbox = useInboxList();
|
|
|
|
const list = useMemo(() => _orderBy(inbox, 'createdAt', 'desc'), [inbox]);
|
|
|
|
const list = useMemo(() => _orderBy(inbox, 'createdAt', 'desc'), [inbox]);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
const renderInbox = (item: InboxItem) => {
|
|
|
|
<CommonSidebarWrapper data-tc-role="sidebar-inbox">
|
|
|
|
|
|
|
|
<div className="overflow-auto">
|
|
|
|
|
|
|
|
{list.map((item) => {
|
|
|
|
|
|
|
|
const { type } = item;
|
|
|
|
const { type } = item;
|
|
|
|
|
|
|
|
|
|
|
|
if (type === 'message') {
|
|
|
|
if (type === 'message') {
|
|
|
@ -38,11 +36,29 @@ export const InboxSidebar: React.FC = React.memo(() => {
|
|
|
|
title={title}
|
|
|
|
title={title}
|
|
|
|
desc={getMessageRender(message.messageSnippet ?? '')}
|
|
|
|
desc={getMessageRender(message.messageSnippet ?? '')}
|
|
|
|
source={'Tailchat'}
|
|
|
|
source={'Tailchat'}
|
|
|
|
|
|
|
|
readed={item.readed}
|
|
|
|
to={`/main/inbox/${item._id}`}
|
|
|
|
to={`/main/inbox/${item._id}`}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fullList = list;
|
|
|
|
|
|
|
|
const unreadList = list.filter((item) => item.readed === false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<CommonSidebarWrapper data-tc-role="sidebar-inbox">
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<PillTabs>
|
|
|
|
|
|
|
|
<PillTabPane key="1" tab={`${t('全部')} (${fullList.length})`}>
|
|
|
|
|
|
|
|
{fullList.map((item) => renderInbox(item))}
|
|
|
|
|
|
|
|
</PillTabPane>
|
|
|
|
|
|
|
|
<PillTabPane key="2" tab={`${t('未读')} (${unreadList.length})`}>
|
|
|
|
|
|
|
|
{unreadList.map((item) => renderInbox(item))}
|
|
|
|
|
|
|
|
</PillTabPane>
|
|
|
|
|
|
|
|
</PillTabs>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</CommonSidebarWrapper>
|
|
|
|
</CommonSidebarWrapper>
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -53,6 +69,7 @@ const InboxSidebarItem: React.FC<{
|
|
|
|
title: React.ReactNode;
|
|
|
|
title: React.ReactNode;
|
|
|
|
desc: React.ReactNode;
|
|
|
|
desc: React.ReactNode;
|
|
|
|
source: string;
|
|
|
|
source: string;
|
|
|
|
|
|
|
|
readed: boolean;
|
|
|
|
to: string;
|
|
|
|
to: string;
|
|
|
|
}> = React.memo((props) => {
|
|
|
|
}> = React.memo((props) => {
|
|
|
|
const location = useLocation();
|
|
|
|
const location = useLocation();
|
|
|
@ -62,10 +79,11 @@ const InboxSidebarItem: React.FC<{
|
|
|
|
<Link to={props.to}>
|
|
|
|
<Link to={props.to}>
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
className={clsx(
|
|
|
|
'p-2 overflow-auto cursor-pointer hover:bg-black hover:bg-opacity-10 dark:hover:bg-white dark:hover:bg-opacity-10',
|
|
|
|
'p-2 overflow-auto cursor-pointer hover:bg-black hover:bg-opacity-10 dark:hover:bg-white dark:hover:bg-opacity-10 border-r-4 rounded',
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'bg-black bg-opacity-10 dark:bg-white dark:bg-opacity-10': isActive,
|
|
|
|
'bg-black bg-opacity-10 dark:bg-white dark:bg-opacity-10': isActive,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
props.readed ? 'border-transparent' : 'border-green-500'
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div className="text-lg overflow-ellipsis overflow-hidden text-gray-700 dark:text-white">
|
|
|
|
<div className="text-lg overflow-ellipsis overflow-hidden text-gray-700 dark:text-white">
|
|
|
|