Skip to content

Commit 6f5239b

Browse files
committed
remove UNSAFE component function and clean up state
1 parent 95407a0 commit 6f5239b

File tree

3 files changed

+6
-38
lines changed

3 files changed

+6
-38
lines changed

ui/src/actions/sampleview.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ export function deleteShapeAction(id) {
101101
return { type: 'DELETE_SHAPE', id };
102102
}
103103

104-
export function saveImageSize(width, height, pixelsPerMm) {
105-
return { type: 'SAVE_IMAGE_SIZE', width, height, pixelsPerMm };
106-
}
107-
108-
export function toggleAutoScale(width = 1) {
109-
return { type: 'TOGGLE_AUTO_SCALE', width };
110-
}
111-
112104
export function videoMessageOverlay(show, msg) {
113105
return { type: 'SHOW_VIDEO_MESSAGE_OVERLAY', show, msg };
114106
}
@@ -146,10 +138,6 @@ export function setShapes(shapes) {
146138
return { type: 'SET_SHAPES', shapes };
147139
}
148140

149-
export function toggleCinema() {
150-
return { type: 'TOOGLE_CINEMA' };
151-
}
152-
153141
export function setGridOverlay(level) {
154142
return { type: 'SET_GRID_OVERLAY', level };
155143
}

ui/src/components/SampleView/SampleImage.jsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,12 @@ export default class SampleImage extends React.Component {
101101
this.initJSMpeg();
102102
}
103103

104-
// eslint-disable-next-line react/no-unsafe
105-
UNSAFE_componentWillReceiveProps(nextProps) {
106-
const { width, cinema } = this.props;
107-
if (
108-
nextProps.width !== width ||
109-
nextProps.cinema !== cinema ||
110-
(nextProps.autoScale && this.props.imageRatio !== nextProps.imageRatio)
111-
) {
104+
componentDidUpdate(prevProps) {
105+
const { imageRatio, width } = this.props; // #NOSONAR
106+
if (imageRatio !== prevProps.imageRatio || width !== prevProps.width) {
107+
// #NOSONAR
112108
this.setImageRatio();
113109
}
114-
115-
this.drawGridPlugin.setScale(nextProps.imageRatio);
116-
}
117-
118-
componentDidUpdate(prevProps) {
119110
// Initialize JSMpeg for decoding the MPEG1 stream
120111
if (prevProps.videoFormat !== 'MPEG1') {
121112
this.initJSMpeg();
@@ -201,10 +192,8 @@ export default class SampleImage extends React.Component {
201192
}
202193

203194
setImageRatio() {
204-
if (this.props.autoScale) {
205-
const { clientWidth } = document.querySelector('#outsideWrapper');
206-
this.props.sampleViewActions.setImageRatio(clientWidth);
207-
}
195+
const { clientWidth } = document.querySelector('#outsideWrapper');
196+
this.props.sampleViewActions.setImageRatio(clientWidth);
208197
}
209198

210199
setVCellSpacing(e) {

ui/src/reducers/sampleview.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const INITIAL_STATE = {
1111
videoURL: '',
1212
sourceIsScalable: false,
1313
videoSizes: [],
14-
autoScale: true,
1514
imageRatio: 0,
1615
pixelsPerMm: [0, 0],
1716
sourceScale: 1,
@@ -21,7 +20,6 @@ const INITIAL_STATE = {
2120
beamPosition: [0, 0],
2221
beamShape: 'ellipse',
2322
beamSize: { x: 0, y: 0 },
24-
cinema: false,
2523
phaseList: [],
2624
drawGrid: false,
2725
videoMessageOverlay: { show: false, msg: '' },
@@ -32,9 +30,6 @@ const INITIAL_STATE = {
3230
// eslint-disable-next-line complexity
3331
function sampleViewReducer(state = INITIAL_STATE, action = {}) {
3432
switch (action.type) {
35-
case 'TOOGLE_CINEMA': {
36-
return { ...state, cinema: !state.cinema };
37-
}
3833
case 'SET_PIXELS_PER_MM': {
3934
return { ...state, pixelsPerMm: action.pixelsPerMm };
4035
}
@@ -99,10 +94,6 @@ function sampleViewReducer(state = INITIAL_STATE, action = {}) {
9994
case 'SET_VIDEO_SIZE': {
10095
return { ...state, videoSize: action.width };
10196
}
102-
case 'TOGGLE_AUTO_SCALE': {
103-
const imageRatio = state.autoScale ? 1 : action.width / state.width;
104-
return { ...state, autoScale: !state.autoScale, imageRatio };
105-
}
10697
case 'SET_APERTURE': {
10798
return { ...state, currentAperture: action.size };
10899
}

0 commit comments

Comments
 (0)