From b2b6824da39800cb2b3abf710d88813128d84df3 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Wed, 16 Mar 2022 11:25:33 +0000 Subject: [PATCH] Derive classifier props from URL params Set classify page state when URL params change. Derive classifier props from classify page state. --- .../src/screens/ClassifyPage/ClassifyPage.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/app-project/src/screens/ClassifyPage/ClassifyPage.js b/packages/app-project/src/screens/ClassifyPage/ClassifyPage.js index e878125e561..e02db27051b 100644 --- a/packages/app-project/src/screens/ClassifyPage/ClassifyPage.js +++ b/packages/app-project/src/screens/ClassifyPage/ClassifyPage.js @@ -39,6 +39,7 @@ function ClassifyPage({ ? ['auto'] : ['1em', 'auto', '1em'] const [classifierProps, setClassifierProps] = useState({}) + const [showTutorial, setShowTutorial] = useState(false) let subjectSetFromUrl if (workflowFromUrl && workflowFromUrl.subjectSets) { @@ -54,15 +55,20 @@ function ClassifyPage({ canClassify = isIndexed ? !!subjectID : canClassify /* - Derive classifier state from the workflow in the URL, when the workflow changes. - Remember the previous classifier state if there's no workflow ID in the URL. + Derive classifier state from the URL, when the URL changes. + Use the previous classifier state if there's no workflow ID in the URL. */ - if (canClassify && classifierProps.workflowID !== workflowID) { + const workflowChanged = classifierProps.workflowID !== workflowID + const subjectSetChanged = classifierProps.subjectSetID !== subjectSetID + const subjectChanged = classifierProps.subjectID !== subjectID + const URLChanged = workflowChanged || subjectSetChanged || subjectChanged + if (canClassify && URLChanged) { setClassifierProps({ workflowID, subjectSetID, subjectID }) + setShowTutorial(true) } return ( @@ -88,7 +94,7 @@ function ClassifyPage({ cachePanoptesData={cachePanoptesData} onAddToCollection={addToCollection} onSubjectReset={onSubjectReset} - showTutorial={canClassify} + showTutorial={showTutorial} {...classifierProps} />