Skip to content
Merged
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
17 changes: 8 additions & 9 deletions frontend/src/routes/scan.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import fetcher from "@utils/fetcher";
import BreadcrumbsContext from "@contexts/breadcrumbs";
import EditableTypography from "@components/EditableTypography";

const Scan = ({ delay = 250 }) => {
const Scan = () => {
const navigate = useNavigate();
const webcamRef = useRef(null);
const [barcode, setBarcode] = useState("");
Expand Down Expand Up @@ -57,24 +57,23 @@ const Scan = ({ delay = 250 }) => {
canvas.toBlob(resolve)
);
const newBarcode = await barcodeDetector.detect(image);
setBarcode(newBarcode);

if (
newBarcode !== barcode &&
newBarcode.length > 0 &&
newBarcode[0].rawValue &&
newBarcode[0].format == "ean_13"
newBarcode[0].format == "ean_13" &&
newBarcode[0].rawValue !== barcode
) {
setBarcode(newBarcode[0].rawValue);
checkForIsbn(newBarcode[0].rawValue);
}
}
};

if (delay !== null) {
const id = setInterval(processImage, delay);
return () => clearInterval(id);
}
}, [delay]);
const id = setInterval(processImage, 100);
return () => clearInterval(id);

}, [barcode]);

useEffect(() => {
const handleResize = () => {
Expand Down
Loading