mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-27 15:27:58 +01:00
27 lines
No EOL
813 B
CoffeeScript
27 lines
No EOL
813 B
CoffeeScript
angular.module('ponyfm').factory('comments', [
|
|
'$rootScope', '$http'
|
|
($rootScope, $http) ->
|
|
commentCache = []
|
|
|
|
self =
|
|
filters: {}
|
|
|
|
addComment: (resourceType, resourceId, content) ->
|
|
commentDef = new $.Deferred()
|
|
$http.post('/api/web/comments/' + resourceType + '/' + resourceId, {content: content, _token: pfm.token}).success (comment) ->
|
|
commentDef.resolve comment
|
|
|
|
commentDef.promise()
|
|
|
|
fetchList: (resourceType, resourceId, force) ->
|
|
key = resourceType + '-' + resourceId
|
|
force = force || false
|
|
return commentCache[key] if !force && commentCache[key]
|
|
commentDef = new $.Deferred()
|
|
$http.get('/api/web/comments/' + resourceType + '/' + resourceId).success (comments) ->
|
|
commentDef.resolve comments
|
|
|
|
commentCache[key] = commentDef.promise()
|
|
|
|
self
|
|
]) |