From 18c6342ce19374de5199978b0e2f8c19135d7f46 Mon Sep 17 00:00:00 2001
From: RaNaN <Mast3rRaNaN@hotmail.de>
Date: Tue, 9 Jul 2013 21:45:02 +0200
Subject: render progress correctly again

---
 pyload/web/app/scripts/models/File.js                   |  5 +++++
 pyload/web/app/scripts/views/dashboard/dashboardView.js | 10 +++++++---
 pyload/web/app/scripts/views/dashboard/fileView.js      |  3 ++-
 pyload/web/app/scripts/views/headerView.js              |  1 +
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/pyload/web/app/scripts/models/File.js b/pyload/web/app/scripts/models/File.js
index 3beb7f270..562e6b0ae 100644
--- a/pyload/web/app/scripts/models/File.js
+++ b/pyload/web/app/scripts/models/File.js
@@ -71,6 +71,11 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], function($
 
         },
 
+        setDownloadStatus: function(status) {
+            if (this.isDownload())
+                this.get('download').status = status;
+        },
+
         isDownload: function() {
             return this.has('download');
         },
diff --git a/pyload/web/app/scripts/views/dashboard/dashboardView.js b/pyload/web/app/scripts/views/dashboard/dashboardView.js
index e7adba475..f305ac2f4 100644
--- a/pyload/web/app/scripts/views/dashboard/dashboardView.js
+++ b/pyload/web/app/scripts/views/dashboard/dashboardView.js
@@ -65,7 +65,6 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection',
             update: function() {
                 console.log('Update package list');
 
-                // TODO: Both null
                 var packs = this.tree.get('packages');
                 this.files = this.tree.get('files');
 
@@ -156,8 +155,13 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection',
 
             // Refresh the file if it is currently shown
             fileUpdated: function(data) {
-                // this works with ids and object
-                var file = this.files.get(data);
+                var fid;
+                if (_.isObject(data))
+                    fid = data.fid;
+                else
+                    fid = data;
+                // this works with ids and object TODO: not anymore
+                var file = this.files.get(fid);
                 if (file)
                     if (_.isObject(data)) // update directly
                         file.set(data);
diff --git a/pyload/web/app/scripts/views/dashboard/fileView.js b/pyload/web/app/scripts/views/dashboard/fileView.js
index 4e5884ed8..ce91a5f38 100644
--- a/pyload/web/app/scripts/views/dashboard/fileView.js
+++ b/pyload/web/app/scripts/views/dashboard/fileView.js
@@ -78,6 +78,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'views/abst
             },
 
             progress_changed: function() {
+                // TODO: progress for non download statuses
                 if (!this.model.isDownload())
                     return;
 
@@ -94,7 +95,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'views/abst
                     this.$('.second').html(
                         '<i class="icon-time"></i>&nbsp;' + formatTime(this.model.get('eta')));
 
-                } else // Every else state can be renderred normally
+                } else // Every else state can be rendered normally
                     this.render();
 
             }
diff --git a/pyload/web/app/scripts/views/headerView.js b/pyload/web/app/scripts/views/headerView.js
index 512c7259b..10e4dfaf9 100644
--- a/pyload/web/app/scripts/views/headerView.js
+++ b/pyload/web/app/scripts/views/headerView.js
@@ -212,6 +212,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle
                                 progress: prog.getPercent(),
                                 eta: prog.get('eta')
                             }, {silent: true});
+                            file.setDownloadStatus(prog.get('download').status);
 
                             file.trigger('change:progress');
                         }
-- 
cgit v1.2.3