Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
support updating the icon status from packages
Browse files Browse the repository at this point in the history
  • Loading branch information
philschatz committed Mar 2, 2016
1 parent 3ccf3ee commit 4302d46
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/directory-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions lib/directory.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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')
Expand Down
7 changes: 7 additions & 0 deletions lib/file-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions lib/file.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 4302d46

Please sign in to comment.