Commit 4fffc02d authored by Randall Leeds's avatar Randall Leeds

Some edge case handling in Guest

parent 494e58d5
...@@ -83,11 +83,14 @@ module.exports = class Guest extends Annotator ...@@ -83,11 +83,14 @@ module.exports = class Guest extends Annotator
uriPromise = Promise.resolve(@plugins.Document.uri()) uriPromise = Promise.resolve(@plugins.Document.uri())
metadataPromise = Promise.resolve(@plugins.Document.metadata) metadataPromise = Promise.resolve(@plugins.Document.metadata)
else else
uriPromise = Promise.resolve(decodeURIComponent(window.location.href)) uriPromise = Promise.reject()
metadataPromise = Promise.resolve({ metadataPromise = Promise.reject()
title: document.title
link: [{href: decodeURIComponent(window.location.href)}] uriPromise = uriPromise.catch(-> decodeURIComponent(window.location.href))
}) metadataPromise = metadataPromise.catch(-> {
title: document.title
link: [{href: decodeURIComponent(window.location.href)}]
})
return metadataPromise.then (metadata) => return metadataPromise.then (metadata) =>
return uriPromise.then (href) => return uriPromise.then (href) =>
...@@ -184,8 +187,8 @@ module.exports = class Guest extends Annotator ...@@ -184,8 +187,8 @@ module.exports = class Guest extends Annotator
annotation.$orphan = false annotation.$orphan = false
self.anchors = self.anchors.concat(anchors) self.anchors = self.anchors.concat(anchors)
self.plugins.BucketBar.update() self.plugins.BucketBar?.update()
self.plugins.CrossFrame.sync([annotation]) self.plugins.CrossFrame?.sync([annotation])
for anchor in self.anchors.splice(0, self.anchors.length) for anchor in self.anchors.splice(0, self.anchors.length)
if anchor.annotation is annotation if anchor.annotation is annotation
...@@ -211,7 +214,7 @@ module.exports = class Guest extends Annotator ...@@ -211,7 +214,7 @@ module.exports = class Guest extends Annotator
return annotation return annotation
createAnnotation: (annotation = {}) -> createAnnotation: (annotation = {}) ->
ranges = @selectedRanges ranges = @selectedRanges ? []
@selectedRanges = null @selectedRanges = null
getSelectors = (range) -> getSelectors = (range) ->
...@@ -252,7 +255,7 @@ module.exports = class Guest extends Annotator ...@@ -252,7 +255,7 @@ module.exports = class Guest extends Annotator
this.anchors = anchors this.anchors = anchors
this.publish('annotationDeleted', [annotation]) this.publish('annotationDeleted', [annotation])
this.plugins.BucketBar.update() this.plugins.BucketBar?.update()
unhighlight = Array::concat(unhighlight...) unhighlight = Array::concat(unhighlight...)
new Promise(raf).then(-> highlighter.removeHighlights(unhighlight)) new Promise(raf).then(-> highlighter.removeHighlights(unhighlight))
......
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