Skip to content

Commit

Permalink
Merge pull request #3544 from zooniverse/fix-classifier-mount
Browse files Browse the repository at this point in the history
Fix classifier mount
  • Loading branch information
amyrebecca authored Mar 6, 2017
2 parents 021bd32 + 7692ae5 commit 104968b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions app/classifier/frame-annotator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
17 changes: 11 additions & 6 deletions app/classifier/index.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion app/collections/favorites-button.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()])
Expand Down

0 comments on commit 104968b

Please sign in to comment.