fix recording update failed (#883)
This commit is contained in:
@@ -64,32 +64,34 @@ export const PronunciationAssessmentForm = () => {
|
||||
}
|
||||
const { language, referenceText } = data;
|
||||
|
||||
let recording: RecordingType;
|
||||
try {
|
||||
setSubmitting(true);
|
||||
const recording = await createRecording(data);
|
||||
toast.promise(
|
||||
createAssessment({
|
||||
language,
|
||||
reference: referenceText,
|
||||
recording,
|
||||
})
|
||||
.then(() => {
|
||||
navigate("/pronunciation_assessments");
|
||||
})
|
||||
.catch(() => {
|
||||
EnjoyApp.recordings.destroy(recording.id);
|
||||
})
|
||||
.finally(() => setSubmitting(false)),
|
||||
{
|
||||
loading: t("assessing"),
|
||||
success: t("assessedSuccessfully"),
|
||||
error: (err) => err.message,
|
||||
}
|
||||
);
|
||||
recording = await createRecording(data);
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
setSubmitting(false);
|
||||
}
|
||||
if (!recording) return;
|
||||
|
||||
setSubmitting(true);
|
||||
toast.promise(
|
||||
createAssessment({
|
||||
language,
|
||||
reference: referenceText,
|
||||
recording,
|
||||
})
|
||||
.then(() => {
|
||||
navigate("/pronunciation_assessments");
|
||||
})
|
||||
.catch(() => {
|
||||
EnjoyApp.recordings.destroy(recording.id);
|
||||
})
|
||||
.finally(() => setSubmitting(false)),
|
||||
{
|
||||
loading: t("assessing"),
|
||||
success: t("assessedSuccessfully"),
|
||||
error: (err) => err.message,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const createRecording = async (
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as sdk from "microsoft-cognitiveservices-speech-sdk";
|
||||
import { useContext } from "react";
|
||||
import { AppSettingsProviderContext } from "@renderer/context";
|
||||
import camelcaseKeys from "camelcase-keys";
|
||||
import { toast } from "@renderer/components/ui";
|
||||
|
||||
export const usePronunciationAssessments = () => {
|
||||
const { webApi, EnjoyApp } = useContext(AppSettingsProviderContext);
|
||||
@@ -18,7 +19,7 @@ export const usePronunciationAssessments = () => {
|
||||
recording = await EnjoyApp.recordings.findOne(targetId);
|
||||
}
|
||||
|
||||
await EnjoyApp.recordings.sync(recording.id);
|
||||
EnjoyApp.recordings.sync(recording.id).catch((err) => toast.error(err));
|
||||
const blob = await (await fetch(recording.src)).blob();
|
||||
targetId = recording.id;
|
||||
targetType = "Recording";
|
||||
|
||||
Reference in New Issue
Block a user