Skip to content

Commit b7875f5

Browse files
committed
fix: issues in code
1 parent 1b81c56 commit b7875f5

File tree

2 files changed

+12
-41
lines changed

2 files changed

+12
-41
lines changed

src/config/appSetting.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export const SettingsKeys = {
88
export type ChatCompletionMessageRoles = 'system' | 'user' | 'assistant';
99

1010
// Chatbot Prompt Setting keys
11-
export enum ChatbotPromptSettingsKeys {
12-
InitialPrompt = 'initialPrompt',
13-
ChatbotCue = 'chatbotCue',
14-
ChatbotName = 'chatbotName',
15-
GptVersion = 'gptVersion',
16-
}
11+
export const ChatbotPromptSettingsKeys = {
12+
InitialPrompt: 'initialPrompt',
13+
ChatbotCue: 'chatbotCue',
14+
ChatbotName: 'chatbotName',
15+
GptVersion: 'gptVersion',
16+
} as const;
1717

1818
export type ChatbotPromptSettings = {
1919
[ChatbotPromptSettingsKeys.InitialPrompt]: ChatBotMessage[];

src/modules/common/Comment.tsx

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { BIG_BORDER_RADIUS, DEFAULT_BOT_USERNAME } from '@/constants';
2929
import ChatbotAvatar from './ChatbotAvatar';
3030
import CommentActions from './CommentActions';
3131
import CommentBody from './CommentBody';
32-
// import { useMembersContext } from '../context/MembersContext';
3332
import CustomAvatar from './CustomAvatar';
3433

3534
const CustomCard = styled(Card)<CardProps>({
@@ -43,46 +42,24 @@ type Props = {
4342

4443
const Comment = ({ comment, onEdit }: Props): JSX.Element => {
4544
const { t, i18n } = useTranslation();
46-
// const members = useMembersContext();
47-
// const {
48-
// // [GENERAL_SETTINGS_NAME]: settings = DEFAULT_GENERAL_SETTINGS,
49-
// } = useSettings();
50-
const currentMemberId = useLocalContext().memberId;
45+
46+
const { accountId } = useLocalContext();
5147
const { data: appContext } = hooks.useAppContext();
52-
const currentMember = appContext?.members.find(
53-
(m) => m.id === currentMemberId,
54-
);
48+
const currentMember = appContext?.members.find((m) => m.id === accountId);
5549
const { data: chatbotPrompts } = hooks.useAppSettings<ChatbotPromptSettings>({
5650
name: SettingsKeys.ChatbotPrompt,
5751
});
5852
const chatbotPrompt = chatbotPrompts?.[0];
59-
// const { mutate: postAppData } = mutations.usePostAppData();
60-
61-
// const allowCommentReporting = true; // settings[GeneralSettingsKeys.AllowCommentsReporting];
6253
const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
6354
const [openActionsMenu, setOpenActionsMenu] = useState(false);
64-
// const [openFlagDialog, setOpenFlagDialog] = useState(false);
6555
const commentRef = useRef<HTMLDivElement>(null);
6656

67-
// currently not using members
68-
// const member = members.find((u) => u.id === comment.memberId);
69-
// const userName = member?.name || ANONYMOUS_USER;
70-
7157
const isBot = comment.type === AppDataTypes.BotComment;
7258

7359
const isEditable = (): boolean =>
74-
!!comment.creator &&
75-
!!currentMemberId &&
76-
comment.creator.id === currentMemberId;
60+
!!comment.creator && !!accountId && comment.creator.id === accountId;
7761
const isDeletable = (): boolean => isEditable();
7862

79-
// const sendCommentReport = (reason: string): void => {
80-
// postAppData({
81-
// data: { reason, commentId: comment.id },
82-
// type: AppDataTypes.FLAG,
83-
// });
84-
// };
85-
8663
return (
8764
<CustomCard
8865
data-cy={buildCommentContainerDataCy(comment.id)}
@@ -92,8 +69,8 @@ const Comment = ({ comment, onEdit }: Props): JSX.Element => {
9269
<CardHeader
9370
title={
9471
isBot
95-
? chatbotPrompt?.data[ChatbotPromptSettingsKeys.ChatbotName] ||
96-
DEFAULT_BOT_USERNAME
72+
? (chatbotPrompt?.data[ChatbotPromptSettingsKeys.ChatbotName] ??
73+
DEFAULT_BOT_USERNAME)
9774
: currentMember?.name
9875
}
9976
subheader={formatDate(comment.updatedAt, { locale: i18n.language })}
@@ -126,12 +103,6 @@ const Comment = ({ comment, onEdit }: Props): JSX.Element => {
126103
}}
127104
onEdit={onEdit}
128105
/>
129-
{/* <ReportCommentDialog
130-
open={openFlagDialog}
131-
setOpen={setOpenFlagDialog}
132-
// onSendReport={sendCommentReport}
133-
commentRef={commentRef}
134-
/> */}
135106
</>
136107
}
137108
/>

0 commit comments

Comments
 (0)