Use angular cache when querying getMusicFolders and getIndexes

It saves us a few requests and helps making Jamstash faster.
It's unlikely that the artists list or the music folders will change during a Jamstash session. It's also an easy cache to reset: the user only has to reload the page.
This commit is contained in:
Hyzual 2015-06-28 21:21:59 +02:00
parent 9c8c8cf6a8
commit d2bdb8eed9

View file

@ -110,8 +110,9 @@ angular.module('jamstash.subsonic.service', [
getMusicFolders: function () {
var exception = { reason: 'No music folder found on the Subsonic server.' };
var promise = subsonicService.subsonicRequest('getMusicFolders.view')
.then(function (subsonicResponse) {
var promise = subsonicService.subsonicRequest('getMusicFolders.view', {
cache: true
}).then(function (subsonicResponse) {
if (subsonicResponse.musicFolders !== undefined && subsonicResponse.musicFolders.musicFolder !== undefined) {
return [].concat(subsonicResponse.musicFolders.musicFolder);
} else {
@ -130,6 +131,7 @@ angular.module('jamstash.subsonic.service', [
};
}
var promise = subsonicService.subsonicRequest('getIndexes.view', {
cache: true,
params: params
}).then(function (subsonicResponse) {
if (subsonicResponse.indexes !== undefined && (subsonicResponse.indexes.index !== undefined || subsonicResponse.indexes.shortcut !== undefined)) {