console.log("MediaItem.findAll: entered.");
app.Store.getMediaItems().done(function(data) {
- data.forEach(function(item) {
- console.log("MediaItem.findAll: pushing object.");
- items.pushObject(app.MediaItem.create(item));
- });
+ if (data !== undefined) {
+ data.forEach(function(item) {
+ console.log("MediaItem.findAll: pushing object.");
+ items.pushObject(app.MediaItem.create(item));
+ });
+ }
});
return items;
}
console.log("Store.scan: entered.");
- if (app.library) {
+ if (app.library !== null) {
app.library.scan().then(function() {
self.scanCompleted = true;
console.log(
"Store.scan: completed. " +
- app.library.size +
+ app.library.getSize() +
" items in the library.");
});
} else {
console.log("Store.getMediaItems: entered.");
if (self.scanCompleted) {
console.log("Store.getMediaItems: scan is completed, resolving promise.");
- d.resolve(app.library.items);
+ d.resolve(app.library.getItems());
} else {
// If the scan is not completed, we must be still scanning.
console.log("Store.getMediaItems: scan still pending. Trying again later.");
console.log("Store.getMediaItem: entered.");
if (self.scanCompleted) {
console.log("Store.getMediaITem: scan is completed, resolving promise.");
- d.resolve(app.library.item(item_id);
+ d.resolve(app.library.item(item_id));
} else {
// If the scan is not completed, we must be still scanning.
console.log("Store.getMediaItem: scan still pending. Trying again later.");