Skip to content

Commit

Permalink
fix: post submission posts updated doc text
Browse files Browse the repository at this point in the history
  • Loading branch information
raynerljm committed Nov 13, 2023
1 parent f1cc010 commit 2378c4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions frontend/app/src/features/room/components/code/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface CodeEditorProps {
className?: string;
roomId: string;
language: LanguageSupport;
setCurrentDocState: Dispatch<SetStateAction<string>>;
}

export const CodeEditor = ({
Expand All @@ -21,6 +22,7 @@ export const CodeEditor = ({
socket,
roomId,
language,
setCurrentDocState,
}: CodeEditorProps) => {
const [version, setVersion] = useState<number | null>(null);
const [isLoading, setLoading] = useState(true);
Expand Down Expand Up @@ -75,6 +77,7 @@ export const CodeEditor = ({
peerExtension(socket, version),
EditorView.lineWrapping,
]}
onChange={value => setCurrentDocState(value)}
value={doc}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const Collaborator = ({
const [activeQuestionId, setActiveQuestionId] = useState(questionId);
// Lifted state from `CodeEditor` component
const [doc, setDoc] = useState<string | null>(null);
const [currentDocState, setCurrentDocState] = useState("");
const toast = useToast();
const { mutate: markAsComplete, isLoading: isPostSubmissionLoading } =
usePostSubmission();
Expand Down Expand Up @@ -151,7 +152,7 @@ export const Collaborator = ({
};

const handleMarkAsComplete = () => {
if (!doc || !activeQuestionId) {
if (!currentDocState || !activeQuestionId) {
toast({
status: "error",
title: "Cannot submit empty code or question",
Expand All @@ -176,7 +177,7 @@ export const Collaborator = ({

markAsComplete({
submission: {
code: doc,
code: currentDocState,
questionId: activeQuestionId.toString(),
lang: languageKey,
...(otherUserId ? { otherUserId } : {}),
Expand Down Expand Up @@ -268,6 +269,7 @@ export const Collaborator = ({
socket={socket}
roomId={roomId}
language={currentLanguage}
setCurrentDocState={setCurrentDocState}
/>
<ChatBubble roomId={roomId} />
</VStack>
Expand All @@ -282,6 +284,7 @@ export const Collaborator = ({
socket={socket}
roomId={roomId}
language={currentLanguage}
setCurrentDocState={setCurrentDocState}
/>
<ChatBubble roomId={roomId} />
</VStack>
Expand Down

0 comments on commit 2378c4a

Please sign in to comment.