mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 22:47:59 +01:00
18e41d2af4
Volume Slider Track Uploader Fav list A bunch of other things And stuff.
41 lines
No EOL
1,016 B
CoffeeScript
41 lines
No EOL
1,016 B
CoffeeScript
angular.module('ponyfm').factory('favourites', [
|
|
'$rootScope', '$http'
|
|
($rootScope, $http) ->
|
|
tracksDef = null
|
|
playlistsDef = null
|
|
albumsDef = null
|
|
|
|
self =
|
|
toggle: (type, id) ->
|
|
def = new $.Deferred()
|
|
$http.post('/api/web/favourites/toggle', {type: type, id: id, _token: pfm.token}).success (res) ->
|
|
def.resolve res
|
|
|
|
def.promise()
|
|
|
|
fetchTracks: (force) ->
|
|
return tracksDef if !force && tracksDef
|
|
tracksDef = new $.Deferred()
|
|
$http.get('/api/web/favourites/tracks').success (res) ->
|
|
tracksDef.resolve res
|
|
|
|
tracksDef
|
|
|
|
fetchAlbums: (force) ->
|
|
return albumsDef if !force && albumsDef
|
|
albumsDef = new $.Deferred()
|
|
$http.get('/api/web/favourites/albums').success (res) ->
|
|
albumsDef.resolve res
|
|
|
|
albumsDef
|
|
|
|
fetchPlaylists: (force) ->
|
|
return playlistsDef if !force && playlistsDef
|
|
playlistsDef = new $.Deferred()
|
|
$http.get('/api/web/favourites/playlists').success (res) ->
|
|
playlistsDef.resolve res
|
|
|
|
playlistsDef
|
|
|
|
self
|
|
]) |