Skip to content

Commit

Permalink
- fixes #1622 and changes defaults for search settings
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Dec 19, 2024
1 parent 3b607e9 commit cdb3f74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/components/preview/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,5 +354,5 @@ const Preview = memo(({ isStateLoaded, hideProjects, isSnapshot = false }) => {
});

export default withLoadingJobSpecs(
withSnapshotManagement(withUpdatingTarget(withLoadingProtein(withLoadingProjects(Preview))))
withLoadingProjects(withSnapshotManagement(withUpdatingTarget(withLoadingProtein(Preview))))
);
18 changes: 16 additions & 2 deletions js/components/target/withLoadingTargetIdList.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React, { memo, useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { loadLegacyTargetList, loadTargetList } from './redux/dispatchActions';
import { useDispatch, useSelector } from 'react-redux';
import { getTargetProjectCombinations, loadLegacyTargetList, loadTargetList } from './redux/dispatchActions';
import { setTargetIdList } from '../../reducers/api/actions';

export const withLoadingTargetList = WrappedComponent => {
return memo(() => {
const dispatch = useDispatch();
const targetIdList = useSelector(state => state.apiReducers.target_id_list);
const projects = useSelector(state => state.targetReducers.projects);

useEffect(() => {
let onCancel = () => {};
Expand All @@ -17,6 +20,17 @@ export const withLoadingTargetList = WrappedComponent => {
};
}, [dispatch]);

useEffect(() => {
if (targetIdList && targetIdList.length > 0 && projects && projects.length > 0) {
const firstTarget = targetIdList[0];
if (typeof firstTarget.project !== 'object') {
const combinations = getTargetProjectCombinations(targetIdList, projects);
const updatedTargets = combinations.map(c => c.updatedTarget);
dispatch(setTargetIdList(updatedTargets));
}
}
}, [dispatch, targetIdList, projects]);

return <WrappedComponent />;
});
};
4 changes: 2 additions & 2 deletions js/reducers/selection/selectionReducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export const INITIAL_STATE = {
searchSettings: {
searchBy: {
shortcode: true,
aliases: false,
compoundId: false
aliases: true,
compoundId: true
}
}
};
Expand Down

0 comments on commit cdb3f74

Please sign in to comment.