From e770e428936aa84c4ce0811c820ef4e43c2cdea3 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 10 Sep 2024 00:03:59 +0800 Subject: [PATCH] perf: improve notification and feed channel filter logic support label filter --- .../components/feed/FeedChannelPicker.tsx | 21 ++++++++------ .../notification/NotificationPicker.tsx | 28 +++++++++++++------ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/client/components/feed/FeedChannelPicker.tsx b/src/client/components/feed/FeedChannelPicker.tsx index 714a220..5a1ece8 100644 --- a/src/client/components/feed/FeedChannelPicker.tsx +++ b/src/client/components/feed/FeedChannelPicker.tsx @@ -1,5 +1,5 @@ import { Button, Empty, Select, SelectProps } from 'antd'; -import React from 'react'; +import React, { useMemo } from 'react'; import { trpc } from '../../api/trpc'; import { useCurrentWorkspaceId } from '../../store/user'; import { PlusOutlined } from '@ant-design/icons'; @@ -16,6 +16,15 @@ export const FeedChannelPicker: React.FC = React.memo( workspaceId, }); + const options = useMemo( + () => + allChannels.map((m) => ({ + label: m.name, + value: m.id, + })), + [allChannels] + ); + return ( + options={options} + optionFilterProp="label" + /> ); } ); diff --git a/src/client/components/notification/NotificationPicker.tsx b/src/client/components/notification/NotificationPicker.tsx index 9f35af6..b84e99f 100644 --- a/src/client/components/notification/NotificationPicker.tsx +++ b/src/client/components/notification/NotificationPicker.tsx @@ -1,5 +1,5 @@ import { Button, Empty, Select, SelectProps } from 'antd'; -import React from 'react'; +import React, { useMemo } from 'react'; import { trpc } from '../../api/trpc'; import { useCurrentWorkspaceId } from '../../store/user'; import { ColorTag } from '../ColorTag'; @@ -17,6 +17,21 @@ export const NotificationPicker: React.FC = React.memo( workspaceId, }); + const options = useMemo( + () => + allNotification.map((notification) => ({ + label: ( +
+ + {notification.name} +
+ ), + value: notification.id, + desc: notification.name, + })), + [allNotification] + ); + return ( + options={options} + optionFilterProp="desc" + /> ); } );