Commit 42c8ac83 authored by Randall Leeds's avatar Randall Leeds

Drop annotator.discardDrafts helper

The annotator service is not a dumping ground for helper functions.
parent 1e5c93a3
......@@ -13,12 +13,12 @@ class App
this.$inject = [
'$location', '$q', '$route', '$scope', '$timeout',
'annotator', 'flash', 'identity', 'socket', 'streamfilter',
'documentHelpers'
'documentHelpers', 'drafts'
]
constructor: (
$location, $q, $route, $scope, $timeout
annotator, flash, identity, socket, streamfilter,
documentHelpers
documentHelpers, drafts
) ->
{plugins, host, providers} = annotator
......@@ -65,7 +65,7 @@ class App
onlogin(assertion)
onlogout: ->
onlogout()
else if annotator.discardDrafts()
else if drafts.discard()
if claimedUser
identity.request()
else
......@@ -324,7 +324,7 @@ class App
update: (query) ->
unless angular.equals $location.search()['q'], query
if annotator.discardDrafts()
if drafts.discard()
$location.search('q', query or null)
$scope.socialView = annotator.socialView
......
......@@ -384,7 +384,7 @@ class Hypothesis extends Annotator
setTool: (name) ->
return if name is @tool
return unless this.discardDrafts()
return unless @element.injector().get('drafts').discard()
if name is 'highlight'
# Check login state first
......@@ -416,10 +416,6 @@ class Hypothesis extends Annotator
method: 'setVisibleHighlights'
params: state
# Discard all drafts, deleting unsaved annotations from the annotator
discardDrafts: ->
return @element.injector().get('drafts').discard()
class DraftProvider
drafts: null
......
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