Commit 1cc8e3c9 authored by csillag's avatar csillag

Simplify annotation card focusing logic

Don't bother looking up the annotations (for the tags),
since we only need the list of tags anyway.

(It was different when we worked with the IDs, but we
moved to use tags instead, so the actual annotations
are no longer needed.)
parent 6c1369bc
...@@ -166,8 +166,7 @@ class Hypothesis extends Annotator ...@@ -166,8 +166,7 @@ class Hypothesis extends Annotator
.bind('setFocusState', (ctx, data) => .bind('setFocusState', (ctx, data) =>
@element.scope().$apply => @element.scope().$apply =>
annotations = this._getLocalAnnotations data.tags this.setViewerFocusState data.tags, data.state
this.setViewerFocusState annotations, data.state
) )
.bind('toggleViewerSelection', (ctx, tags=[]) => .bind('toggleViewerSelection', (ctx, tags=[]) =>
...@@ -237,14 +236,14 @@ class Hypothesis extends Annotator ...@@ -237,14 +236,14 @@ class Hypothesis extends Annotator
@_setSelectedAnnotations selected @_setSelectedAnnotations selected
this this
setViewerFocusState: (annotations, state) -> setViewerFocusState: (tags, state) ->
scope = @element.scope() scope = @element.scope()
focused = scope.focusedAnnotations ?= {} focused = scope.focusedAnnotations ?= {}
for a in annotations for tag in tags
if state if state
focused[a.$$tag] = true focused[tag] = true
else else
delete focused[a.$$tag] delete focused[tag]
this this
updateViewer: (annotations=[]) -> updateViewer: (annotations=[]) ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment