fix: throttle thumbnail progress updates (#2557)
This commit is contained in:
parent
f6e2e58aad
commit
66c587b139
@ -1,5 +1,6 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import throttle from 'lodash.throttle';
|
||||||
import { useDrag } from 'react-dnd';
|
import { useDrag } from 'react-dnd';
|
||||||
import { classes } from '@ohif/core';
|
import { classes } from '@ohif/core';
|
||||||
import ImageThumbnail from './ImageThumbnail';
|
import ImageThumbnail from './ImageThumbnail';
|
||||||
@ -144,13 +145,13 @@ function Thumbnail(props) {
|
|||||||
|
|
||||||
const [stackPercentComplete, setStackPercentComplete] = useState(0);
|
const [stackPercentComplete, setStackPercentComplete] = useState(0);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onProgressChange = ({ detail }) => {
|
const onProgressChange = throttle(({ detail }) => {
|
||||||
const { progressId, progressData } = detail;
|
const { progressId, progressData } = detail;
|
||||||
if (`StackProgress:${displaySetInstanceUID}` === progressId) {
|
if (`StackProgress:${displaySetInstanceUID}` === progressId) {
|
||||||
const percent = progressData ? progressData.percentComplete : 0;
|
const percent = progressData ? progressData.percentComplete : 0;
|
||||||
setStackPercentComplete(percent);
|
setStackPercentComplete(percent);
|
||||||
}
|
}
|
||||||
};
|
}, 100);
|
||||||
|
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
StudyLoadingListener.events.OnProgress,
|
StudyLoadingListener.events.OnProgress,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user