From aa51cda3f939acf87cb0d59be55e7ba9ca9f15f0 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 6 Mar 2017 11:08:38 +0000 Subject: [PATCH 1/4] Mount the classifier page once from the wrapper Update subjects and classifications when props change. --- app/classifier/index.cjsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/classifier/index.cjsx b/app/classifier/index.cjsx index a827de2927..78b719fd38 100644 --- a/app/classifier/index.cjsx +++ b/app/classifier/index.cjsx @@ -77,11 +77,18 @@ Classifier = React.createClass componentWillReceiveProps: (nextProps) -> if nextProps.subject isnt @props.subject - @loadSubject subject - if nextProps.classification isnt @props.classification - @prepareToClassify nextProps.classification + @loadSubject nextProps.subject if @props.subject isnt nextProps.subject or !@context.geordi?.keys["subjectID"]? @context.geordi?.remember subjectID: nextProps.subject?.id + + if nextProps.classification isnt @props.classification + @props.classification.stopListening 'change', => + {annotations} = @props.classification + @setState {annotations} + nextProps.classification.listen 'change', => + {annotations} = nextProps.classification + @setState {annotations} + @prepareToClassify nextProps.classification componentWillMount: () -> interventionMonitor.setProjectSlug @props.project.slug @@ -619,9 +626,7 @@ module.exports = React.createClass @loadClassification nextProps.classification loadClassification: (classification) -> - @setState subject: null - - # TODO: These underscored references are temporary stopgaps. +# TODO: These underscored references are temporary stopgaps. Promise.resolve(classification._subjects ? classification.get 'subjects').then ([subject]) => # We'll only handle one subject per classification right now. From 53e5d71c6573c821e845b4c681cab9783b3eacbb Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 6 Mar 2017 11:09:24 +0000 Subject: [PATCH 2/4] Check for favourited status on subject update --- app/collections/favorites-button.cjsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/collections/favorites-button.cjsx b/app/collections/favorites-button.cjsx index c99ef61df1..b451503bc7 100644 --- a/app/collections/favorites-button.cjsx +++ b/app/collections/favorites-button.cjsx @@ -56,6 +56,12 @@ module.exports = React.createClass .then (favorited) => @setState {favorited} + componentDidUpdate: (prevProps) -> + if prevProps.subject isnt @props.subject + @findSubjectInCollection(@state.favorites) + .then (favorited) => + @setState {favorited} + addSubjectTo: (collection) -> @setState favorited: true collection.addLink('subjects', [@props.subject.id.toString()]) From befe50fd3218e6ac5810442228daa6f413f5869e Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 6 Mar 2017 11:13:19 +0000 Subject: [PATCH 3/4] Update subject seen status on props change --- app/classifier/frame-annotator.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/classifier/frame-annotator.jsx b/app/classifier/frame-annotator.jsx index 1eaa73c6c0..065febab07 100644 --- a/app/classifier/frame-annotator.jsx +++ b/app/classifier/frame-annotator.jsx @@ -28,6 +28,9 @@ export default class FrameAnnotator extends React.Component { if (nextProps.annotation !== this.props.annotation) { this.handleAnnotationChange(this.props.annotation, nextProps.annotation); } + if (nextProps.subject !== this.props.subject) { + this.setState({ alreadySeen: nextProps.subject.already_seen || seenThisSession.check(nextProps.workflow, nextProps.subject) }); + } } getSizeRect() { From 7692ae555ed129ac3a07d0dc7d41031f4b54cf42 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 6 Mar 2017 13:26:22 +0000 Subject: [PATCH 4/4] Always return a Promise for favourites --- app/collections/favorites-button.cjsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/collections/favorites-button.cjsx b/app/collections/favorites-button.cjsx index b451503bc7..ddbeede59d 100644 --- a/app/collections/favorites-button.cjsx +++ b/app/collections/favorites-button.cjsx @@ -44,7 +44,7 @@ module.exports = React.createClass favorites.get('subjects', id: @props.subject.id) .then ([subject]) -> subject? else - false + Promise.resolve false componentWillMount: -> # see if the subject is in the project's favorites collection