Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/pages/Task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,19 @@ export default function Task({ type }: { type: "task" | "example" }) {
return `data:${file.mimeType};base64,` + file.templateBinary
}

const getContent = (file: TaskFileProps) =>
editor.getContent(getPath(file.id)) || file.template
const getContent = (file: TaskFileProps) => {
const editorContent = editor.getContent(getPath(file.id))

if (editorContent) return editorContent

const lastestSubmissionContent = task.submissions[0].files.find(
(f) => f.taskFileId === file.id,
)?.content

if (lastestSubmissionContent) return lastestSubmissionContent

return file.template
}

const onSubmit = (command: string) => () => {
submit({
Expand Down