Skip to content

Commit

Permalink
refactor: reset exifData at redux state at initial render
Browse files Browse the repository at this point in the history
  • Loading branch information
bijayrauniyar0 committed Nov 27, 2024
1 parent 05a39a9 commit d31bc79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { toast } from 'react-toastify';
Expand All @@ -14,6 +14,7 @@ import { Button } from '@Components/RadixComponents/Button';
import { Label } from '@Components/common/FormUI';
import SwitchTab from '@Components/common/SwitchTab';
import {
resetFilesExifData,
setSelectedTaskDetailToViewOrthophoto,
setUploadedImagesType,
} from '@Store/actions/droneOperatorTask';
Expand Down Expand Up @@ -67,6 +68,10 @@ const DescriptionBox = () => {
},
});

useEffect(() => {
dispatch(resetFilesExifData());
}, [dispatch]);

const { mutate: reStartImageryProcess, isLoading: imageProcessingStarting } =
useMutation({
mutationFn: () =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-await-in-loop */
import { Button } from '@Components/RadixComponents/Button';
import { toggleModal } from '@Store/actions/common';
import { setFiles, setFilesExifData } from '@Store/actions/droneOperatorTask';
import { setFilesExifData } from '@Store/actions/droneOperatorTask';
import { useTypedDispatch, useTypedSelector } from '@Store/hooks';
import getExifData from '@Utils/getExifData';
import { toast } from 'react-toastify';
Expand All @@ -12,15 +12,16 @@ const UploadsBox = ({
label?: string;
}) => {
const dispatch = useTypedDispatch();
const files = useTypedSelector(state => state.droneOperatorTask.files);
const files = useTypedSelector(
state => state.droneOperatorTask.filesExifData,
);
const handleFileChange = async (
event: React.ChangeEvent<HTMLInputElement>,
) => {
event.preventDefault();
const selectedFiles = event.target.files;
if (!selectedFiles || selectedFiles?.length === 0) return;
const selectedFilesArray: File[] = Array.from(selectedFiles);
dispatch(setFiles(selectedFilesArray));
try {
const exifData = await Promise.all(
selectedFilesArray.map(async (file: File) => {
Expand Down

0 comments on commit d31bc79

Please sign in to comment.