Ignore noisy events that are unimportant

This commit is contained in:
Kevin Sawicki
2013-01-02 11:59:18 -08:00
parent 109770805d
commit d155ed7bc7
2 changed files with 20 additions and 2 deletions

View File

@@ -38,3 +38,13 @@ describe "CommandLogger", ->
expect(commandLogger.eventLog['core:backspace'].count).toBe 1
rootView.trigger 'command-logger:clear-data'
expect(commandLogger.eventLog['core:backspace']).toBeUndefined()
describe "when an event is ignored", ->
it "does not create a node for that event", ->
commandLogger.ignoredEvents.push 'editor:delete-line'
editor.trigger 'editor:delete-line'
nodes = commandLogger.createNodes()
for node in nodes
continue unless node.name is 'Editor'
for child in node.children
expect(child.name.indexOf('Delete Line')).toBe -1

View File

@@ -18,6 +18,13 @@ class CommandLogger extends ScrollView
@instance.serialize()
eventLog: null
ignoredEvents: [
'core:backspace'
'core:cancel'
'core:confirm'
'editor:newline'
'tree-view:directory-modified'
]
initialize: (@rootView, @eventLog={}) ->
super
@@ -50,9 +57,10 @@ class CommandLogger extends ScrollView
else
@attach()
createRootChildren: ->
createNodes: ->
categories = {}
for eventName, details of @eventLog
continue if _.contains(@ignoredEvents, eventName)
categoryStart = eventName.indexOf(':')
if categoryStart is -1
categoryName = 'Uncategorized'
@@ -77,7 +85,7 @@ class CommandLogger extends ScrollView
addTreeMap: ->
root =
name: 'All'
children: @createRootChildren()
children: @createNodes()
node = root
@treeMap.empty()