Skip to content

Commit

Permalink
fix lost connexion
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilSpartans committed Aug 2, 2024
1 parent 4cc60cb commit 6483de2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
25 changes: 19 additions & 6 deletions src/components/cv-video/Film.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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(""));

Expand Down Expand Up @@ -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 () => {
Expand All @@ -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) {
Expand All @@ -337,13 +343,20 @@ export default function Film() {
};

const handleRedoRecording = () => {
setIsSavingVideo(false);
setLostConnexion(null);
setVideoBase64(null);
setCreatedVideoPath(null);
setTimer(0);
clearInterval(timerIntervalId);
setMediaStream(null);
};

const resetLostConnexion = () => {
setIsSavingVideo(false);
setLostConnexion(null);
};

const formatTime = (seconds) => {
const hours = Math.floor(seconds / 3600)
.toString()
Expand Down Expand Up @@ -477,7 +490,7 @@ export default function Film() {
</p>
<button
className="mt-4 bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-700"
onClick={handleRedoRecording}
onClick={resetLostConnexion}
>
Réessayer l'enregistrement
</button>
Expand Down

0 comments on commit 6483de2

Please sign in to comment.