diff --git a/.vscode/launch.json b/.vscode/launch.json index 24e3ce2..c2490fd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,13 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "command": "npm run dev", + "name": "Client", + "request": "launch", + "type": "node-terminal", + "cwd": "${workspaceFolder}/client" + }, { "name": "Server", "type": "debugpy", @@ -23,5 +30,14 @@ "--prod" ] }, + ], + "compounds": [ + { + "name": "Server/Client", + "configurations": [ + "Client", + "Server", + ] + } ] } \ No newline at end of file diff --git a/client/src/Context/TrialChoosing.js b/client/src/Context/TrialChoosing.js index daf6af7..94db191 100644 --- a/client/src/Context/TrialChoosing.js +++ b/client/src/Context/TrialChoosing.js @@ -15,7 +15,21 @@ export class TrialChoosing { const experimentIndex = allExperiments.findIndex(t => t.name === experimentName); if (experimentIndex >= 0) { const experiment = allExperiments[experimentIndex]; - const trialTypeIndex = ((experiment || {}).trialTypes || []).findIndex(t => t.name === trialTypeName); + const trialTypes = (experiment || {}).trialTypes || []; + + if (!trialTypeName && trialTypes.length > 0) { + const trialType = experiment.trialTypes[0]; + const trials = (trialType || {}).trials || []; + if (trials.length > 0) { + return { + experimentName, experimentIndex, + trialTypeName: trialType.name, trialTypeIndex: 0, + trialName: trials[0].name, trialIndex: 0, + }; + } + } + + const trialTypeIndex = trialTypes.findIndex(t => t.name === trialTypeName); if (trialTypeIndex >= 0) { const trialType = experiment.trialTypes[trialTypeIndex]; const trialIndex = ((trialType || {}).trials || []).findIndex(t => t.name === trialName); @@ -26,11 +40,11 @@ export class TrialChoosing { trialName, trialIndex, }; } - } else { - return { - experimentName, experimentIndex, - }; } + + return { + experimentName, experimentIndex, + }; } } return {}; diff --git a/client/src/Experiment/ExperimentList.jsx b/client/src/Experiment/ExperimentList.jsx index b03a8c7..59e1d0d 100644 --- a/client/src/Experiment/ExperimentList.jsx +++ b/client/src/Experiment/ExperimentList.jsx @@ -48,7 +48,9 @@ export const ExperimentList = ({ fullscreen, showConfig, setShowConfig }) => { const foundExperiment = findExperimentByUuid(newlyExpanded[0]); if (foundExperiment) { - setCurrTrial({ experimentName: foundExperiment.name }); + if (experiment.name !== foundExperiment.name) { + setCurrTrial({ experimentName: foundExperiment.name }); + } const newNodes = [ foundExperiment.trackUuid, ...nodeIds.filter(u => !findExperimentByUuid(u)),