Move starring songs to subsonic-service

So we keep all requests to subsonic in the same place and all use subsonicRequest()
This commit is contained in:
Hyzual 2015-05-14 13:39:59 +02:00
parent 832c410290
commit b96fe0ecf0
14 changed files with 108 additions and 66 deletions

View file

@ -1,6 +1,6 @@
angular.module('JamStash')
.controller('AppController', ['$scope', '$rootScope', '$document', '$window', '$location', '$cookieStore', '$http', 'utils', 'globals', 'model', 'notifications', 'player', 'persistence', 'Page',
function($scope, $rootScope, $document, $window, $location, $cookieStore, $http, utils, globals, model, notifications, player, persistence, Page) {
.controller('AppController', ['$scope', '$rootScope', '$document', '$window', '$location', '$cookieStore', '$http', 'utils', 'globals', 'model', 'notifications', 'player', 'persistence', 'Page', 'subsonic',
function ($scope, $rootScope, $document, $window, $location, $cookieStore, $http, utils, globals, model, notifications, player, persistence, Page, subsonic) {
'use strict';
$rootScope.settings = globals.settings;
@ -380,27 +380,13 @@ angular.module('JamStash')
});
};
$scope.updateFavorite = function (item) {
var id = item.id;
var starred = item.starred;
var url;
if (starred) {
url = globals.BaseURL() + '/unstar.view?' + globals.BaseParams() + '&id=' + id;
item.starred = undefined;
} else {
url = globals.BaseURL() + '/star.view?' + globals.BaseParams() + '&id=' + id;
item.starred = true;
}
$.ajax({
url: url,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function () {
notifications.updateMessage('Favorite Updated!', true);
}
$scope.toggleStar = function (item) {
subsonic.toggleStar(item).then(function (newStarred) {
item.starred = newStarred;
notifications.updateMessage('Favorite Updated!', true);
});
};
$scope.toTrusted = function (html) {
return $sce.trustAsHtml(html);
};