Skip to content

Commit

Permalink
feat(ChatDraft): refactor unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanSaleem committed Oct 29, 2024
1 parent 1d8767f commit b644696
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
6 changes: 0 additions & 6 deletions frontend/src/components/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ const ChatBox = ({
const [openChatDraftDrawer, setOpenChatDraftDrawer] =
useState<boolean>(false);

const [scrollToEditorBottom, setScrollToEditorBottom] =
useState<boolean>(false);

const { data: statusData, isLoading } = useQuery({
queryKey: ["chatStatus", project_id],
queryFn: async () => {
Expand Down Expand Up @@ -118,7 +115,6 @@ const ChatBox = ({
draftedMessageIndexes: [...chatDraft.draftedMessageIndexes, index],
});
setOpenChatDraftDrawer(true);
setScrollToEditorBottom(true);
};

const onCloseChatDraft = () => {
Expand All @@ -127,7 +123,6 @@ const ChatBox = ({

const onOpenChatDraft = () => {
setOpenChatDraftDrawer(true);
setScrollToEditorBottom(false);
};

const handleDraftEdit = (draft: string) => {
Expand Down Expand Up @@ -228,7 +223,6 @@ const ChatBox = ({
draft={chatDraft?.draft}
onCancel={onCloseChatDraft}
onSubmit={handleDraftEdit}
scrollToEnd={scrollToEditorBottom}
/>
</div>
);
Expand Down
9 changes: 1 addition & 8 deletions frontend/src/components/ChatDraftDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface IProps {
isOpen?: boolean;
onCancel: () => void;
onSubmit: (data: string) => void;
scrollToEnd?: boolean;
}

const modules = {
Expand Down Expand Up @@ -47,17 +46,11 @@ const ChatDraftDrawer = ({
draft,
onSubmit,
onCancel,
scrollToEnd = false,
}: IProps) => {
const quillRef = useRef<ReactQuill | null>(null);

const setEditedSummary = (data: string) => {
onSubmit(data);
};

useEffect(() => {
if (quillRef.current) {
console.log("Exists!");
const editor = quillRef.current.getEditor();
const editorContainer = editor.root;
if (editorContainer) {
Expand All @@ -73,7 +66,7 @@ const ChatDraftDrawer = ({
ref={quillRef}
theme="snow"
value={draft}
onChange={setEditedSummary}
onChange={onSubmit}
modules={modules}
formats={formats}
/>
Expand Down

0 comments on commit b644696

Please sign in to comment.