mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-23 21:47:59 +01:00
27 lines
No EOL
647 B
CoffeeScript
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
|
|
]) |