diff --git a/lib/directory-view.coffee b/lib/directory-view.coffee index 784c64f2..3c415c9f 100644 --- a/lib/directory-view.coffee +++ b/lib/directory-view.coffee @@ -52,6 +52,8 @@ class DirectoryView extends HTMLElement else @draggable = true @subscriptions.add @directory.onDidStatusChange => @updateStatus() + @subscriptions.add @directory.onDidIconStatusChange (iconStatus) => + @updateIconStatus(iconStatus) @updateStatus() @expand() if @directory.expansionState.isExpanded @@ -60,6 +62,12 @@ class DirectoryView extends HTMLElement @classList.remove('status-ignored', 'status-modified', 'status-added') @classList.add("status-#{@directory.status}") if @directory.status? + updateIconStatus: (newIconStatus) -> + if newIconStatus isnt @iconStatus and @iconStatus + @classList.remove(@iconStatus) + @classList.add(newIconStatus) if newIconStatus + @iconStatus = newIconStatus + subscribeToDirectory: -> @subscriptions.add @directory.onDidAddEntries (addedEntries) => return unless @isExpanded diff --git a/lib/directory.coffee b/lib/directory.coffee index 73e0ed84..482cb66a 100644 --- a/lib/directory.coffee +++ b/lib/directory.coffee @@ -48,6 +48,9 @@ class Directory onDidStatusChange: (callback) -> @emitter.on('did-status-change', callback) + onDidIconStatusChange: (callback) -> + @emitter.on('did-icon-status-change', callback) + onDidAddEntries: (callback) -> @emitter.on('did-add-entries', callback) @@ -91,6 +94,11 @@ class Directory @status = newStatus @emitter.emit('did-status-change', newStatus) + updateIconStatus: (newIconStatus) -> + if newIconStatus isnt @iconStatus + @iconStatus = newIconStatus + @emitter.emit('did-icon-status-change', newIconStatus) + # Is the given path ignored? isPathIgnored: (filePath) -> if atom.config.get('tree-view.hideVcsIgnoredFiles') diff --git a/lib/file-view.coffee b/lib/file-view.coffee index dc65a1c9..2a92cd29 100644 --- a/lib/file-view.coffee +++ b/lib/file-view.coffee @@ -22,12 +22,19 @@ class FileView extends HTMLElement @fileName.classList.add(FileIcons.getService().iconClassForPath(@file.path)) @subscriptions.add @file.onDidStatusChange => @updateStatus() + @subscriptions.add @file.onDidIconStatusChange (iconStatus) => @updateIconStatus(iconStatus) @updateStatus() updateStatus: -> @classList.remove('status-ignored', 'status-modified', 'status-added') @classList.add("status-#{@file.status}") if @file.status? + updateIconStatus: (newIconStatus) -> + if newIconStatus isnt @iconStatus and @iconStatus + @classList.remove(@iconStatus) + @classList.add(newIconStatus) if newIconStatus + @iconStatus = newIconStatus + getPath: -> @fileName.dataset.path diff --git a/lib/file.coffee b/lib/file.coffee index 657839a5..f2889beb 100644 --- a/lib/file.coffee +++ b/lib/file.coffee @@ -33,6 +33,9 @@ class File onDidStatusChange: (callback) -> @emitter.on('did-status-change', callback) + onDidIconStatusChange: (callback) -> + @emitter.on('did-icon-status-change', callback) + # Subscribe to the project' repo for changes to the Git status of this file. subscribeToRepo: -> repo = repoForPath(@path) @@ -62,5 +65,10 @@ class File @status = newStatus @emitter.emit('did-status-change', newStatus) + updateIconStatus: (newIconStatus) -> + if newIconStatus isnt @iconStatus + @iconStatus = newIconStatus + @emitter.emit('did-icon-status-change', newIconStatus) + isPathEqual: (pathToCompare) -> @path is pathToCompare or @realPath is pathToCompare