Commit 1d588521 authored by Randall Leeds's avatar Randall Leeds

Use showViewSort for all the things

I think this better ensures #1135 is fixed cleanly. Before, the
controls might hide after the timeout, but the user may be on their
way to click it. Now, everything goes through showViewSort, and it
manages timeout cancellation.

Also, moved the view and sort controls out to the app.pt. Because
they're essentially global now, and we should move to kill the viewer,
editor, search distinction anyway.
parent 0ca279b5
...@@ -165,17 +165,18 @@ class App ...@@ -165,17 +165,18 @@ class App
# Show the sort/view control for a while. # Show the sort/view control for a while.
# #
# hide: should we hide it after a second? # hide: should we hide it after a second?
$rootScope.showViewSort = (hide = false) => _vstp = null
unless $scope.show_view_sort $rootScope.showViewSort = (show = true, hide = false) ->
$scope.show_view_sort = true if _vstp then $timeout.cancel _vstp
if hide $rootScope.viewState.showControls = show
$timeout -> if $rootScope.viewState.showControls and hide
$scope.show_view_sort = false _vstp = $timeout (-> $rootScope.viewState.showControls = false), 1000
, 1000
# "View" -- which annotations are shown # "View" -- which annotations are shown
$rootScope.applyView = (view) -> $rootScope.applyView = (view) ->
return if $rootScope.viewState.view is view
$rootScope.viewState.view = view $rootScope.viewState.view = view
$rootScope.showViewSort true, true
switch view switch view
when 'Screen' when 'Screen'
# Go over all providers, and switch them to dynamic mode # Go over all providers, and switch them to dynamic mode
...@@ -195,12 +196,18 @@ class App ...@@ -195,12 +196,18 @@ class App
comments = annotations.filter (a) -> annotator.isComment(a) comments = annotations.filter (a) -> annotator.isComment(a)
$rootScope.annotations = comments $rootScope.annotations = comments
when 'Selection'
for p in providers
p.channel.notify method: 'setDynamicBucketMode', params: false
else else
throw new Error "Unknown view requested: " + view throw new Error "Unknown view requested: " + view
# "Sort" -- order annotations are shown # "Sort" -- order annotations are shown
$rootScope.applySort = (sort) -> $rootScope.applySort = (sort) ->
return if $rootScope.viewState.sort is sort
$rootScope.viewState.sort = sort $rootScope.viewState.sort = sort
$rootScope.showViewSort true, true
if sort == 'Newest' if sort == 'Newest'
$scope.predicate = 'updated' $scope.predicate = 'updated'
$scope.reverse = true $scope.reverse = true
...@@ -557,11 +564,12 @@ class Annotation ...@@ -557,11 +564,12 @@ class Annotation
switch $scope.action switch $scope.action
when 'create' when 'create'
if annotator.isComment(annotation) switch
if $rootScope.viewState.view isnt "Comments" when annotator.isComment(annotation) and
$rootScope.viewState.view isnt "Comments"
$rootScope.applyView "Comments" $rootScope.applyView "Comments"
else if not annotator.isReply(annotation) and when not annotator.isReply(annotation) and
$rootScope.viewState.view in ["Comments"] $rootScope.viewState.view not in ["Document", "Selection"]
$rootScope.applyView "Screen" $rootScope.applyView "Screen"
annotator.publish 'annotationCreated', annotation annotator.publish 'annotationCreated', annotation
when 'delete' when 'delete'
......
...@@ -354,10 +354,7 @@ class Hypothesis extends Annotator ...@@ -354,10 +354,7 @@ class Hypothesis extends Annotator
($rootScope) => ($rootScope) =>
@buildReplyList annotations @buildReplyList annotations
$rootScope.annotations = annotations $rootScope.annotations = annotations
unless $rootScope.viewState.view is viewName $rootScope.applyView viewName
# We are changing the view
$rootScope.viewState.view = viewName
$rootScope.showViewSort true
] ]
this this
......
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