Consolidate Git status checking

Now the status bar and tree view both listen for
status change events and use the cached information
available from the git object to update their views.
This commit is contained in:
Kevin Sawicki
2013-02-27 18:37:39 -08:00
parent 2ec4d558ba
commit 4fe6db240b
8 changed files with 47 additions and 30 deletions

View File

@@ -38,6 +38,13 @@ class Git
@refreshIndex()
@refreshStatus()
project?.eachBuffer this, (buffer) =>
bufferStatusHandler = =>
path = buffer.getPath()
@getPathStatus(path) if path
@subscribe buffer, 'saved', bufferStatusHandler
@subscribe buffer, 'reloaded', bufferStatusHandler
getRepo: ->
unless @repo?
throw new Error("Repository has been destroyed")

View File

@@ -128,9 +128,15 @@ class Project
buffers.push editSession.buffer
buffers
eachBuffer: (callback) ->
eachBuffer: (args...) ->
subscriber = args.shift() if args.length > 1
callback = args.shift()
callback(buffer) for buffer in @getBuffers()
@on 'buffer-created', (buffer) -> callback(buffer)
if subscriber
subscriber.subscribe this, 'buffer-created', (buffer) -> callback(buffer)
else
@on 'buffer-created', (buffer) -> callback(buffer)
bufferForPath: (filePath) ->
if filePath?

View File

@@ -69,9 +69,11 @@ window.shutdown = ->
rootView: rootView.serialize()
rootView.deactivate()
project.destroy()
git?.destroy()
$(window).off('focus blur before')
window.rootView = null
window.project = null
window.git = null
window.installAtomCommand = (commandPath) ->
return if fs.exists(commandPath)