From 6483de2ec6ff935d92a14d91a83d1bf7499656fc Mon Sep 17 00:00:00 2001
From: Alexis Moren
Date: Fri, 2 Aug 2024 13:26:36 +0200
Subject: [PATCH] fix lost connexion
---
package.json | 2 +-
src/components/cv-video/Film.js | 25 +++++++++++++++++++------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/package.json b/package.json
index 71132c1..254fd24 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jobibox",
- "version": "1.6.4",
+ "version": "1.6.5",
"description": "La cabine accoustique pour créer un cv vidéo",
"repository": "https://github.com/EvilSpartans/JobiBox",
"main": "main.js",
diff --git a/src/components/cv-video/Film.js b/src/components/cv-video/Film.js
index dd69233..69a373b 100644
--- a/src/components/cv-video/Film.js
+++ b/src/components/cv-video/Film.js
@@ -36,7 +36,6 @@ export default function Film() {
const videoCameraRef = useRef(null);
const [mediaStream, setMediaStream] = useState(null);
const [mediaRecorder, setMediaRecorder] = useState(null);
- const [createdVideoId, setCreatedVideoId] = useState(null);
const [createdVideoPath, setCreatedVideoPath] = useState(null);
const [cameraLoading, setCameraLoading] = useState(true);
const [isFilterApplied, setIsFilterApplied] = useState(false);
@@ -81,10 +80,10 @@ export default function Film() {
}, []);
useEffect(() => {
- if (!mediaStream && !showIntro) {
+ if (!mediaStream && !showIntro && !lostConnexion) {
initializeCamera();
}
- }, [mediaStream, showIntro]);
+ }, [mediaStream, showIntro, lostConnexion]);
// Make Pad working
const handleKeyPress = (event) => {
@@ -272,7 +271,6 @@ export default function Film() {
if (res.meta.requestStatus === "fulfilled") {
success = true;
- setCreatedVideoId(res.payload.id);
setCreatedVideoPath(res.payload.video);
dispatch(changeStatus(""));
@@ -300,8 +298,11 @@ export default function Film() {
if (!success) {
console.error("Échec de la sauvegarde du clip après plusieurs tentatives.");
setLostConnexion(true);
+ return false;
}
+
setIsSavingVideo(false);
+ return true;
};
const handleNextQuestion = async () => {
@@ -314,12 +315,17 @@ export default function Film() {
type: "video/mp4",
});
- await saveVideoToDatabase(
+ const success = await saveVideoToDatabase(
videoFile,
questionId,
selectedQuestion,
token
);
+
+ if (!success) {
+ return;
+ }
+
}
if (currentQuestionIndex < questions.length - 1) {
@@ -337,6 +343,8 @@ export default function Film() {
};
const handleRedoRecording = () => {
+ setIsSavingVideo(false);
+ setLostConnexion(null);
setVideoBase64(null);
setCreatedVideoPath(null);
setTimer(0);
@@ -344,6 +352,11 @@ export default function Film() {
setMediaStream(null);
};
+ const resetLostConnexion = () => {
+ setIsSavingVideo(false);
+ setLostConnexion(null);
+ };
+
const formatTime = (seconds) => {
const hours = Math.floor(seconds / 3600)
.toString()
@@ -477,7 +490,7 @@ export default function Film() {