(hoofbeats) Update store with latest library API changes.
authorSalvatore Iovene <salvatore@iovene.com>
Mon, 18 Mar 2013 07:48:20 +0000 (09:48 +0200)
committerSalvatore Iovene <salvatore@iovene.com>
Mon, 18 Mar 2013 07:48:20 +0000 (09:48 +0200)
examples/hoofbeats/javascripts/app/models/mediaItemModel.js
examples/hoofbeats/javascripts/app/store.js

index 90ec418..7ca7458 100644 (file)
 
             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;
index 44f18b0..ddbe9f0 100644 (file)
             }
 
             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 {
@@ -41,7 +41,7 @@
             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.");
@@ -60,7 +60,7 @@
             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.");