Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
6f8b0d19
Commit
6f8b0d19
authored
Jan 03, 2014
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be smart w cleaning up in-flight Store requests
Fix #575
parent
1aeadf01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
controllers.coffee
h/js/controllers.coffee
+33
-3
No files found.
h/js/controllers.coffee
View file @
6f8b0d19
...
@@ -366,11 +366,10 @@ class App
...
@@ -366,11 +366,10 @@ class App
$scope
.
new_updates
=
0
$scope
.
new_updates
=
0
$scope
.
$root
.
annotations
=
[]
$scope
.
$root
.
annotations
=
[]
annotator
.
threading
.
thread
[]
annotator
.
threading
.
thread
[]
annotator
.
threading
.
idTable
=
{}
Store
=
annotator
.
plugins
.
Store
Store
=
annotator
.
plugins
.
Store
annotations
=
Store
.
annotations
annotations
=
Store
.
annotations
.
slice
()
annotator
.
plugins
.
Store
.
annotations
=
[]
annotator
.
deleteAnnotation
a
for
a
in
annotations
# XXX: Hacky hacky stuff to ensure that any search requests in-flight
# XXX: Hacky hacky stuff to ensure that any search requests in-flight
# at this time have no effect when they resolve and that future events
# at this time have no effect when they resolve and that future events
...
@@ -383,12 +382,43 @@ class App
...
@@ -383,12 +382,43 @@ class App
Store
.
annotator
=
loadAnnotations
:
angular
.
noop
Store
.
annotator
=
loadAnnotations
:
angular
.
noop
# * Make all api requests into a noop.
# * Make all api requests into a noop.
Store
.
_apiRequest
=
angular
.
noop
Store
.
_apiRequest
=
angular
.
noop
# * Ignore pending searches
Store
.
_onLoadAnnotations
=
angular
.
noop
# * Make the update function into a noop.
# * Make the update function into a noop.
Store
.
updateAnnotation
=
angular
.
noop
Store
.
updateAnnotation
=
angular
.
noop
# * Remove the plugin and re-add it to the annotator.
# * Remove the plugin and re-add it to the annotator.
delete
annotator
.
plugins
.
Store
delete
annotator
.
plugins
.
Store
annotator
.
addPlugin
'Store'
,
annotator
.
options
.
Store
annotator
.
addPlugin
'Store'
,
annotator
.
options
.
Store
# Even though most operations on the old Store are now noops the Annotator
# itself may still be setting up previously fetched annotatiosn. We may
# delete annotations which are later set up in the DOM again, causing
# issues with the viewer and heatmap. As these are loaded, we can delete
# them, but the threading plugin will get confused and break threading.
# Here, we cleanup these annotations as they are set up by the Annotator,
# preserving the existing threading. This is all a bit paranoid, but
# important when many annotations are loading as authentication is
# changing. It's all so ugly it makes me cry, though. Someone help
# restore sanity?
cleanup
=
(
loaded
)
->
$timeout
->
# Give the threading plugin time to thread this annotation
deleted
=
[]
for
l
in
loaded
if
l
in
annotations
# If this annotation still exists, we'll need to thread it again
# since the delete will mangle the threading data structures.
existing
=
annotator
.
threading
.
idTable
[
l
.
id
]
?
.
message
annotator
.
deleteAnnotation
(
l
)
deleted
.
push
l
if
existing
annotator
.
plugins
.
Threading
.
thread
existing
annotations
=
(
a
for
a
in
annotations
when
a
not
in
deleted
)
if
annotations
.
length
is
0
annotator
.
unsubscribe
'annotationsLoaded'
,
cleanup
,
10
cleanup
(
a
for
a
in
annotations
when
a
.
thread
)
annotator
.
subscribe
'annotationsLoaded'
,
cleanup
# Notifications
# Notifications
$scope
.
notifications
=
[]
$scope
.
notifications
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment