Pony.fm/resources/assets/scripts/app/services/account-albums.coffee
2015-08-31 16:42:23 +01:00

27 lines
No EOL
647 B
CoffeeScript

angular.module('ponyfm').factory('account-albums', [
'$rootScope', '$http'
($rootScope, $http) ->
def = null
albums = []
self =
getEdit: (id, force) ->
url = '/api/web/albums/edit/' + id
force = force || false
return albums[id] if !force && albums[id]
editDef = new $.Deferred()
albums[id] = editDef
$http.get(url).success (album) -> editDef.resolve album
editDef.promise()
refresh: (force) ->
force = force || false
return def if !force && def
def = new $.Deferred()
$http.get('/api/web/albums/owned').success (ownedAlbums) ->
def.resolve(ownedAlbums)
def.promise()
self
])