Skip to content

Commit

Permalink
feat: allow @ feature in conversation #212
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Feb 23, 2024
1 parent 1359b6e commit 3ee37d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions client/web/src/components/ChatBox/ChatInputBox/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export function useChatInputActionContext() {
* Input Mentions
*/
interface ChatInputMentionsContextProps extends PropsWithChildren {
users: SuggestionDataItem[];
panels: SuggestionDataItem[];
users?: SuggestionDataItem[];
panels?: SuggestionDataItem[];
placeholder?: string;
disabled?: boolean;
}
Expand Down
24 changes: 19 additions & 5 deletions client/web/src/components/Panel/personal/ConversePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
t,
useAppSelector,
useDMConverseName,
useUserId,
useUserInfoList,
} from 'tailchat-shared';
import { CommonPanelWrapper } from '../common/Wrapper';
import _compact from 'lodash/compact';
Expand All @@ -17,6 +19,7 @@ import { IconBtn } from '@/components/IconBtn';
import { DMPluginPanelActionProps, pluginPanelActions } from '@/plugin/common';
import { CreateDMConverse } from '@/components/modals/CreateDMConverse';
import { MessageSearchPanel } from '../common/MessageSearch';
import { ChatInputMentionsContextProvider } from '@/components/ChatBox/ChatInputBox/context';

const ConversePanelTitle: React.FC<{ converse: ChatConverseState }> =
React.memo(({ converse }) => {
Expand Down Expand Up @@ -47,6 +50,10 @@ export const ConversePanel: React.FC<ConversePanelProps> = React.memo(
const converse = useAppSelector(
(state) => state.chat.converses[converseId]
);
const userId = useUserId();
const userInfos = useUserInfoList(
(converse?.members ?? []).filter((m) => m !== userId)
);

const { hasOpenedPanel, openPanelWindow, closePanelWindow } =
usePanelWindow(`/panel/personal/converse/${converseId}`);
Expand Down Expand Up @@ -152,11 +159,18 @@ export const ConversePanel: React.FC<ConversePanelProps> = React.memo(
]);
}}
>
<ChatBox
converseId={converseId}
converseTitle={converseHeader}
isGroup={false}
/>
<ChatInputMentionsContextProvider
users={userInfos.map((m) => ({
id: m._id,
display: m.nickname,
}))}
>
<ChatBox
converseId={converseId}
converseTitle={converseHeader}
isGroup={false}
/>
</ChatInputMentionsContextProvider>
</CommonPanelWrapper>
);
}
Expand Down

0 comments on commit 3ee37d6

Please sign in to comment.