From 86a1a7c9e26d899d34af4f6cdb85ceb19f207d0d Mon Sep 17 00:00:00 2001 From: Boris Kovar Date: Tue, 15 Aug 2023 09:49:39 +0200 Subject: [PATCH] Squashed commit of the following: commit 0550be26180579a58c85c520b0930c44f4999011 Author: Boris Kovar Date: Tue Aug 15 08:46:33 2023 +0200 - fixed #1092 --- js/components/nglView/renderingObjects.js | 2 +- js/reducers/ngl/dispatchActions.js | 58 ++++++++++++----------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/js/components/nglView/renderingObjects.js b/js/components/nglView/renderingObjects.js index 070da083a..22a56f43a 100644 --- a/js/components/nglView/renderingObjects.js +++ b/js/components/nglView/renderingObjects.js @@ -355,7 +355,7 @@ const showArrow = ({ stage, input_dict, object_name, representations, orientatio let radius = input_dict.radius === undefined ? 0.3 : input_dict.radius; // Handle undefined start and finish if (input_dict.start === undefined || input_dict.end === undefined) { - const msgs = 'START OR END UNDEFINED FOR ARROW ' + input_dict.toString(); + const msgs = 'START OR END UNDEFINED FOR ARROW ' + JSON.stringify(input_dict); return Promise.reject(msgs); } let shape = new Shape(object_name, { disableImpostor: true }); diff --git a/js/reducers/ngl/dispatchActions.js b/js/reducers/ngl/dispatchActions.js index c36420e90..830afad77 100644 --- a/js/reducers/ngl/dispatchActions.js +++ b/js/reducers/ngl/dispatchActions.js @@ -97,36 +97,38 @@ export const loadObject = ({ }; export const deleteObject = (target, stage, deleteFromSelections) => dispatch => { - const comps = stage.getComponentsByName(target.name); - comps.list.forEach(component => stage.removeComponent(component)); - - if (deleteFromSelections === true && target && target.selectionType && target.moleculeId) { - const objectId = { id: target.moleculeId }; - switch (target.selectionType) { - case SELECTION_TYPE.LIGAND: - dispatch(removeFromFragmentDisplayList(objectId)); - break; - case SELECTION_TYPE.HIT_PROTEIN: - dispatch(removeFromProteinList(objectId)); - break; - case SELECTION_TYPE.COMPLEX: - dispatch(removeFromComplexList(objectId)); - break; - case SELECTION_TYPE.SURFACE: - dispatch(removeFromSurfaceList(objectId)); - break; - case SELECTION_TYPE.DENSITY: - dispatch(removeFromDensityList(objectId)); - dispatch(removeFromDensityListCustom(objectId, true)); - dispatch(removeFromDensityListType({ id: objectId })); - break; - case SELECTION_TYPE.VECTOR: - dispatch(removeFromVectorOnList(objectId)); - break; + if (stage && target) { + const comps = stage.getComponentsByName(target.name); + comps.list.forEach(component => stage.removeComponent(component)); + + if (deleteFromSelections === true && target && target.selectionType && target.moleculeId) { + const objectId = { id: target.moleculeId }; + switch (target.selectionType) { + case SELECTION_TYPE.LIGAND: + dispatch(removeFromFragmentDisplayList(objectId)); + break; + case SELECTION_TYPE.HIT_PROTEIN: + dispatch(removeFromProteinList(objectId)); + break; + case SELECTION_TYPE.COMPLEX: + dispatch(removeFromComplexList(objectId)); + break; + case SELECTION_TYPE.SURFACE: + dispatch(removeFromSurfaceList(objectId)); + break; + case SELECTION_TYPE.DENSITY: + dispatch(removeFromDensityList(objectId)); + dispatch(removeFromDensityListCustom(objectId, true)); + dispatch(removeFromDensityListType({ id: objectId })); + break; + case SELECTION_TYPE.VECTOR: + dispatch(removeFromVectorOnList(objectId)); + break; + } } - } - dispatch(deleteNglObject(target)); + dispatch(deleteNglObject(target)); + } }; export const checkRemoveFromDensityList = (target, objectsInView) => () => {