Fixed the track editor sometimes not working after uploading a track.

This commit is contained in:
Peter Deltchev 2016-02-15 11:05:58 -08:00
parent bd9a525393
commit b345601faf
2 changed files with 8 additions and 14 deletions

View file

@ -27,7 +27,6 @@ angular.module('ponyfm').controller "account-tracks", [
selectedTrack: null
$scope.tracks = []
tracksDb = {}
setTracks = (tracks) ->
@ -40,26 +39,20 @@ angular.module('ponyfm').controller "account-tracks", [
if $state.params.track_id
$scope.data.selectedTrack = tracksDb[$state.params.track_id]
tracks.refresh().done setTracks
$scope.refreshList = () ->
tracks.refresh().done setTracks
$scope.selectTrack = (track) ->
$scope.data.selectedTrack = track
tracks.refresh().done setTracks
$scope.$on '$stateChangeSuccess', () ->
if $state.params.track_id
$scope.selectTrack tracksDb[$state.params.track_id]
else
$scope.selectTrack null
$scope.$on 'track-updated', (track) ->
tracks.clearCache()
$scope.refreshList()
$scope.$on 'track-deleted', () ->
$state.transitionTo 'account.tracks'
tracks.clearCache()
$scope.refreshList()
tracks.refresh(null, true).done setTracks
]

View file

@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
angular.module('ponyfm').factory('upload', [
'$rootScope', '$http', '$timeout'
($rootScope, $http, $timeout) ->
'$rootScope', '$http', '$timeout', 'account-tracks'
($rootScope, $http, $timeout, accountTracks) ->
self =
queue: []
@ -94,7 +94,8 @@ angular.module('ponyfm').factory('upload', [
upload.error = error
$rootScope.$broadcast 'upload-error', [upload, error]
$rootScope.$broadcast 'upload-finished', upload
accountTracks.refresh(null, true)
.done($rootScope.$broadcast('upload-finished', upload))
# send the track to the server
formData = new FormData();