Podcast/js/queueList.js
2013-08-06 08:13:36 +02:00

34 lines
933 B
JavaScript

angular.module('podcasts.queueList', ['podcasts.database'])
.run(['queueList', function(queueList) {
queueList.rebuildList();
}])
.service('queueList', ['db', '$rootScope', function(db, $rootScope) {
var queueList = [];
function getQueueList() {
return queueList;
}
function rebuildList() {
queueList = [];
db.get("feedItem", IDBKeyRange.only(1), "ixQueued")
.then(function(results) {
angular.forEach(results, function(item) {
if (item.queued) {
queueList.push(item);
}
});
$rootScope.$apply();
});
}
return {
rebuildList: rebuildList,
getQueueList: function() {
return queueList;
}
};
}])
;