use new queuelist
This commit is contained in:
parent
43ffa9c186
commit
e1539e4d33
2 changed files with 43 additions and 5 deletions
|
@ -52,10 +52,8 @@ function FeedCtrl($scope, $routeParams, $location, feeds, pageSwitcher) {
|
|||
pageSwitcher.setBack('feeds');
|
||||
}
|
||||
|
||||
function QueueListCtrl($scope, $rootScope, pageSwitcher, feedItems, feeds, queueList) {
|
||||
$scope.queue = [];
|
||||
queueList.init($scope);
|
||||
feedItems.listQueue(queueList);
|
||||
function QueueListCtrl($scope, $rootScope, pageSwitcher, feedItems, feeds, downloader, newQueueList) {
|
||||
$scope.queue = newQueueList.getQueueList();
|
||||
|
||||
$scope.playItem = function(id) {
|
||||
feedItems.get(id, function(feedItem) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
/* Services */
|
||||
angular.module('podcasts.services', ['podcasts.utilities'])
|
||||
angular.module('podcasts.services', ['podcasts.utilities', 'podcasts.queueList'])
|
||||
.value('queueList', {
|
||||
queue: [],
|
||||
scope: null,
|
||||
|
@ -828,6 +828,46 @@ angular.module('podcasts.settings', ['podcasts.database'])
|
|||
}])
|
||||
;
|
||||
|
||||
angular.module('podcasts.queueList', ['podcasts.database'])
|
||||
.run(['newQueueList', function(queueList) {
|
||||
queueList.rebuildList();
|
||||
}])
|
||||
.service('newQueueList', ['db', '$rootScope', function(oldDb, $rootScope) {
|
||||
var queueList = [];
|
||||
|
||||
function getQueueList() {
|
||||
return queueList;
|
||||
}
|
||||
|
||||
function rebuildList() {
|
||||
oldDb.getCursor("feedItem", function(ixDbCursorReq)
|
||||
{
|
||||
if(typeof ixDbCursorReq !== "undefined") {
|
||||
ixDbCursorReq.onsuccess = function (e) {
|
||||
var cursor = ixDbCursorReq.result || e.result;
|
||||
if (cursor) {
|
||||
// This additional check is necessary, since the index doesn't seem to always catch correctly
|
||||
if (cursor.value.queued) {
|
||||
queueList.push(cursor.value);
|
||||
}
|
||||
|
||||
cursor.continue();
|
||||
} else {
|
||||
$rootScope.$apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, undefined, IDBKeyRange.only(1), false, 'ixQueued');
|
||||
}
|
||||
|
||||
return {
|
||||
rebuildList: rebuildList,
|
||||
getQueueList: getQueueList
|
||||
};
|
||||
}])
|
||||
;
|
||||
|
||||
|
||||
angular.module('podcasts.importer', ['podcasts.utilities', 'podcasts.services'])
|
||||
.service('opml', ['xmlParser', 'feeds', function(xmlParser, feeds) {
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue