Skip to content

Commit

Permalink
Remove the remnants of a defunct annotation pulse feature
Browse files Browse the repository at this point in the history
Another feature that used to work but now doesn't. Remove the code for
now, as it's just bloat that is, at best, doing nothing.
  • Loading branch information
nickstenning committed Oct 27, 2015
1 parent bccfa89 commit 3f99019
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 86 deletions.
1 change: 0 additions & 1 deletion h/static/scripts/app.coffee
Expand Up @@ -147,7 +147,6 @@ module.exports = angular.module('h', [
.service('host', require('./host'))
.service('localStorage', require('./local-storage'))
.service('permissions', require('./permissions'))
.service('pulse', require('./pulse'))
.service('queryParser', require('./query-parser'))
.service('render', require('./render'))
.service('searchFilter', require('./search-filter'))
Expand Down
5 changes: 0 additions & 5 deletions h/static/scripts/directive/annotation.coffee
Expand Up @@ -387,11 +387,6 @@ AnnotationController = [
# Discard saved drafts
drafts.remove model

# Propagate an update event up the thread (to pulse changing threads),
# but only if this is someone else's annotation.
if model.user != session.state.userid
$scope.$emit('annotationUpdate')

# Save highlights once logged in.
if this.isHighlight() and highlight
if model.user and not model.id
Expand Down
18 changes: 0 additions & 18 deletions h/static/scripts/directive/test/annotation-test.coffee
Expand Up @@ -486,24 +486,6 @@ describe 'annotation', ->
$document.click()
assert.notOk(dialog.hasClass('open'))

describe 'annotationUpdate event', ->
beforeEach ->
createDirective()
sandbox.spy(isolateScope, '$emit')
annotation.updated = '123'
$scope.$digest()

it "does not fire when this user's annotations are updated", ->
annotation.updated = '456'
$scope.$digest()
assert.notCalled(isolateScope.$emit)

it "fires when another user's annotation is updated", ->
fakeSession.state.userid = 'acct:jane@localhost'
annotation.updated = '456'
$scope.$digest()
assert.calledWith(isolateScope.$emit, 'annotationUpdate')

describe "deleteAnnotation() method", ->
before ->
sinon.stub(window, "confirm")
Expand Down
31 changes: 0 additions & 31 deletions h/static/scripts/directive/test/thread-test.coffee
Expand Up @@ -6,7 +6,6 @@ describe 'thread', ->
$scope = null
controller = null
fakeGroups = null
fakePulse = null
fakeRender = null
fakeAnnotationUI = null
sandbox = null
Expand All @@ -29,7 +28,6 @@ describe 'thread', ->
fakeGroups = {
focused: sandbox.stub().returns({id: '__world__'})
}
fakePulse = sandbox.spy()
fakeRender = sandbox.spy()
fakeAnnotationUI = {
hasSelectedAnnotations: ->
Expand All @@ -38,7 +36,6 @@ describe 'thread', ->
selectedAnnotations.indexOf(id) != -1
}
$provide.value 'groups', fakeGroups
$provide.value 'pulse', fakePulse
$provide.value 'render', fakeRender
$provide.value 'annotationUI', fakeAnnotationUI
return
Expand Down Expand Up @@ -351,31 +348,3 @@ describe 'thread', ->
controller.container = {}
assert.isFalse(controller.matchesFilter())
assert.calledWith(check, controller.container)

describe 'directive', ->
beforeEach ->
createDirective()

it 'pulses the current thread on an annotationUpdated event', ->
$element.scope().$emit('annotationUpdate')
assert.called(fakePulse)

it 'does not pulse the thread if it is hidden (parent collapsed)', ->
fakeParent = {
controller: -> {collapsed: true}
}
sandbox.stub(angular.element.prototype, 'parent').returns(fakeParent)
$element.scope().$emit('annotationUpdate')
assert.notCalled(fakePulse)

it 'does not pulse the thread if it is hidden (grandparent collapsed)', ->
fakeGrandParent = {
controller: -> {collapsed: true}
}
fakeParent = {
controller: -> {collapsed: false}
parent: -> fakeGrandParent
}
sandbox.stub(angular.element.prototype, 'parent').returns(fakeParent)
$element.scope().$emit('annotationUpdate')
assert.notCalled(fakePulse)
13 changes: 2 additions & 11 deletions h/static/scripts/directive/thread.coffee
Expand Up @@ -219,8 +219,8 @@ isHiddenThread = (elem) ->
# Directive that instantiates {@link thread.ThreadController ThreadController}.
###
module.exports = [
'$parse', '$window', '$location', '$anchorScroll', 'pulse', 'render',
($parse, $window, $location, $anchorScroll, pulse, render) ->
'$parse', '$window', '$location', '$anchorScroll', 'render',
($parse, $window, $location, $anchorScroll, render) ->
linkFn = (scope, elem, attrs, [ctrl, counter, filter]) ->

# We would ideally use require for this, but searching parents only for a
Expand All @@ -239,15 +239,6 @@ module.exports = [
counter.count 'message', 1
scope.$on '$destroy', -> counter.count 'message', -1

# Flash the thread when any child annotations are updated.
scope.$on 'annotationUpdate', (event) ->
# If we're hidden, we let the event propagate up to the parent thread.
if isHiddenThread(elem)
return
# Otherwise, stop the event from bubbling, and pulse this thread.
event.stopPropagation()
pulse(elem)

# The watch is necessary because the computed value of the attribute
# expression may change. This won't happen when we use the thread
# directive in a repeat, since the element will be torn down whenever the
Expand Down
12 changes: 0 additions & 12 deletions h/static/scripts/pulse.coffee

This file was deleted.

8 changes: 0 additions & 8 deletions h/static/styles/threads.scss
Expand Up @@ -28,14 +28,6 @@ $thread-padding: 1em;
margin-left: -$thread-padding;
}

@keyframes pulse {
10% { background-color: #ffc; }
}

&.pulse {
animation: pulse 1200ms ease-in-out;
}

.thread {
border-left: 1px dotted $gray-light;
padding: 0;
Expand Down

0 comments on commit 3f99019

Please sign in to comment.