From 8bbb34e6d1a08822d250388c6da2c6c79ce1467c Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Thu, 21 Jan 2021 12:11:56 +0000 Subject: [PATCH] Catch workflow ID errors in the classifier Allow workflow ID and subject set ID to be set after the classifier has mounted. --- .../src/components/Classifier/Classifier.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/lib-classifier/src/components/Classifier/Classifier.js b/packages/lib-classifier/src/components/Classifier/Classifier.js index 071dd79ee34..9b65ffb02e7 100644 --- a/packages/lib-classifier/src/components/Classifier/Classifier.js +++ b/packages/lib-classifier/src/components/Classifier/Classifier.js @@ -65,15 +65,25 @@ export default class Classifier extends React.Component { this.classifierStore.setOnAddToCollection(onAddToCollection) this.classifierStore.classifications.setOnComplete(onCompleteClassification) this.classifierStore.setOnToggleFavourite(onToggleFavourite) - this.classifierStore.workflows.selectWorkflow(workflowID, subjectSetID) + if (workflowID) { + this.classifierStore.workflows.selectWorkflow(workflowID, subjectSetID) + } } componentDidUpdate (prevProps) { - const { authClient, project } = this.props + const { authClient, project, subjectSetID, workflowID } = this.props if (project.id !== prevProps.project.id) { this.setProject(project) } + if (workflowID !== prevProps.workflowID) { + this.classifierStore.workflows.selectWorkflow(workflowID, subjectSetID) + } + + if (subjectSetID !== prevProps.subjectSetID) { + this.classifierStore.workflows.selectWorkflow(workflowID, subjectSetID) + } + if (authClient) { this.classifierStore.userProjectPreferences.checkForUser() }