Commit 04de6f74 authored by Randall Leeds's avatar Randall Leeds

On highlight mode, check social view / auth

For #798
parent add53021
......@@ -31,9 +31,9 @@ class App
authentication.token = null
# Leave Highlighting mode when logging out
if $scope.highlightingMode
if annotator.tool is 'highlight'
# Because of logging out, we must leave Highlighting Mode.
$scope.toggleHighlightingMode()
annotator.setTool 'comment'
# No need to reload annotations after login, since the Social View
# change (caused by leaving Highlighting Mode) will trigger
# a reload anyway.
......@@ -67,7 +67,7 @@ class App
if $scope.ongoingHighlightSwitch
$timeout =>
$scope.toggleHighlightingMode()
annotator.setTool 'highlight'
, 500
else
plugins.Permissions.setUser(null)
......@@ -176,33 +176,6 @@ class App
method: 'setAlwaysOnMode'
params: $scope.alwaysOnMode
$scope.highlightingMode = false
$scope.toggleHighlightingMode = ->
# Check for drafts
return unless annotator.discardDrafts()
# Check login state first
unless plugins.Auth? and plugins.Auth.haveValidToken()
# If we are not logged in, start the auth process
$scope.ongoingHighlightSwitch = true
# No need to reload annotations upon login, since Social View change
# will trigger a reload anyway.
$scope.skipAuthChangeReload = true
annotator.show()
$scope.sheet.collapsed = false
$scope.sheet.tab = 'login'
return
delete $scope.ongoingHighlightSwitch
$scope.highlightingMode = not $scope.highlightingMode
annotator.socialView.name =
if $scope.highlightingMode then "single-player" else "none"
for p in providers
p.channel.notify
method: 'setHighlightingMode'
params: $scope.highlightingMode
$scope.createUnattachedAnnotation = ->
return unless annotator.discardDrafts()
provider.notify method: 'addComment'
......
......@@ -450,9 +450,26 @@ class Hypothesis extends Annotator
setTool: (name) =>
return if name is @tool
if tool is 'highlight'
scope = @element.scope()
if name is 'highlight'
return unless this.discardDrafts()
# Check login state first
unless @plugins.Auth? and @plugins.Auth.haveValidToken()
# If we are not logged in, start the auth process
scope.ongoingHighlightSwitch = true
# No need to reload annotations upon login, since Social View change
# will trigger a reload anyway.
scope.skipAuthChangeReload = true
scope.sheet.collapsed = false
scope.sheet.tab = 'login'
this.show()
return
this.socialView.name = 'single-player'
else
this.socialView.name = 'none'
@tool = name
this.publish 'setTool', name
for p in @providers
......
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