diff --git a/resources/assets/scripts/app/controllers/account-tracks.coffee b/resources/assets/scripts/app/controllers/account-tracks.coffee index 358bf250..5deda9ba 100644 --- a/resources/assets/scripts/app/controllers/account-tracks.coffee +++ b/resources/assets/scripts/app/controllers/account-tracks.coffee @@ -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 ] diff --git a/resources/assets/scripts/app/services/upload.coffee b/resources/assets/scripts/app/services/upload.coffee index 06a13852..a9657fbd 100644 --- a/resources/assets/scripts/app/services/upload.coffee +++ b/resources/assets/scripts/app/services/upload.coffee @@ -15,8 +15,8 @@ # along with this program. If not, see . 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();