Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 0 additions & 12 deletions ui/src/actions/sampleview.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ export function deleteShapeAction(id) {
return { type: 'DELETE_SHAPE', id };
}

export function saveImageSize(width, height, pixelsPerMm) {
return { type: 'SAVE_IMAGE_SIZE', width, height, pixelsPerMm };
}
Comment on lines -103 to -105
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that this action was also never called, so removed it. Instead there is an action called setVideoSize which is used by mxcube, to change the above parameters.


export function toggleAutoScale(width = 1) {
return { type: 'TOGGLE_AUTO_SCALE', width };
}

export function videoMessageOverlay(show, msg) {
return { type: 'SHOW_VIDEO_MESSAGE_OVERLAY', show, msg };
}
Expand Down Expand Up @@ -145,10 +137,6 @@ export function setShapes(shapes) {
return { type: 'SET_SHAPES', shapes };
}

export function toggleCinema() {
return { type: 'TOOGLE_CINEMA' };
}

export function setGridOverlay(level) {
return { type: 'SET_GRID_OVERLAY', level };
}
Expand Down
23 changes: 6 additions & 17 deletions ui/src/components/SampleView/SampleImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,12 @@ export default class SampleImage extends React.Component {
this.initJSMpeg();
}

// eslint-disable-next-line react/no-unsafe
UNSAFE_componentWillReceiveProps(nextProps) {
const { width, cinema } = this.props;
if (
nextProps.width !== width ||
nextProps.cinema !== cinema ||
(nextProps.autoScale && this.props.imageRatio !== nextProps.imageRatio)
) {
componentDidUpdate(prevProps) {
const { imageRatio, width } = this.props; // #NOSONAR
if (imageRatio !== prevProps.imageRatio || width !== prevProps.width) {
// #NOSONAR
this.setImageRatio();
}

this.drawGridPlugin.setScale(nextProps.imageRatio);
}

componentDidUpdate(prevProps) {
// Initialize JSMpeg for decoding the MPEG1 stream
if (prevProps.videoFormat !== 'MPEG1') {
this.initJSMpeg();
Expand Down Expand Up @@ -201,10 +192,8 @@ export default class SampleImage extends React.Component {
}

setImageRatio() {
if (this.props.autoScale) {
const { clientWidth } = document.querySelector('#outsideWrapper');
this.props.sampleViewActions.setImageRatio(clientWidth);
}
const { clientWidth } = document.querySelector('#outsideWrapper');
this.props.sampleViewActions.setImageRatio(clientWidth);
}

setVCellSpacing(e) {
Expand Down
9 changes: 0 additions & 9 deletions ui/src/reducers/sampleview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const INITIAL_STATE = {
videoURL: '',
sourceIsScalable: false,
videoSizes: [],
autoScale: true,
imageRatio: 0,
pixelsPerMm: [0, 0],
sourceScale: 1,
Expand All @@ -21,7 +20,6 @@ const INITIAL_STATE = {
beamPosition: [0, 0],
beamShape: 'ellipse',
beamSize: { x: 0, y: 0 },
cinema: false,
phaseList: [],
drawGrid: false,
videoMessageOverlay: { show: false, msg: '' },
Expand All @@ -32,9 +30,6 @@ const INITIAL_STATE = {
// eslint-disable-next-line complexity
function sampleViewReducer(state = INITIAL_STATE, action = {}) {
switch (action.type) {
case 'TOOGLE_CINEMA': {
return { ...state, cinema: !state.cinema };
}
case 'SET_PIXELS_PER_MM': {
return { ...state, pixelsPerMm: action.pixelsPerMm };
}
Expand Down Expand Up @@ -99,10 +94,6 @@ function sampleViewReducer(state = INITIAL_STATE, action = {}) {
case 'SET_VIDEO_SIZE': {
return { ...state, videoSize: action.width };
}
case 'TOGGLE_AUTO_SCALE': {
const imageRatio = state.autoScale ? 1 : action.width / state.width;
return { ...state, autoScale: !state.autoScale, imageRatio };
}
case 'SET_APERTURE': {
return { ...state, currentAperture: action.size };
}
Expand Down