fix: throttle thumbnail progress updates (#2557)

This commit is contained in:
Erik Ziegler 2021-09-24 12:58:30 +02:00 committed by GitHub
parent f6e2e58aad
commit 66c587b139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import throttle from 'lodash.throttle';
import { useDrag } from 'react-dnd';
import { classes } from '@ohif/core';
import ImageThumbnail from './ImageThumbnail';
@ -144,13 +145,13 @@ function Thumbnail(props) {
const [stackPercentComplete, setStackPercentComplete] = useState(0);
useEffect(() => {
const onProgressChange = ({ detail }) => {
const onProgressChange = throttle(({ detail }) => {
const { progressId, progressData } = detail;
if (`StackProgress:${displaySetInstanceUID}` === progressId) {
const percent = progressData ? progressData.percentComplete : 0;
setStackPercentComplete(percent);
}
};
}, 100);
document.addEventListener(
StudyLoadingListener.events.OnProgress,