From d6b5fa699392b5b85850678eea444d6b1b343e73 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 11 Apr 2014 18:32:17 +0000 Subject: [PATCH] check if video is done while in a view that might benefit from it: info or video view --- static/js/item.js | 3 ++- static/js/utils.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/static/js/item.js b/static/js/item.js index 212f6ce0..8f87ce44 100644 --- a/static/js/item.js +++ b/static/js/item.js @@ -52,7 +52,7 @@ pandora.ui.item = function() { +'{1} view.', [result.data.title, Ox._(pandora.user.ui.itemView)]) ) ); - + pandora.updateStatus(pandora.user.ui.item); } else if (pandora.user.ui.itemView == 'info') { pandora.$ui.contentPanel.replaceElement(1, @@ -63,6 +63,7 @@ pandora.ui.item = function() { } }) ); + !result.data.rendered && pandora.updateStatus(pandora.user.ui.item); } else if (pandora.user.ui.itemView == 'documents') { diff --git a/static/js/utils.js b/static/js/utils.js index 218c8aeb..40f83c90 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -2279,6 +2279,48 @@ pandora.updateItemContext = function() { } }; +pandora.updateStatus = function(item) { + var ui = pandora.user.ui; + item = item || ui.item; + if (pandora.$ui.updateStatus && pandora.$ui.updateStatus[item]) { + return; + } + pandora.$ui.updateStatus = pandora.$ui.updateStatus || {}; + pandora.$ui.updateStatus[item] = setTimeout(function() { + if(isActive()) { + Ox.Request.clearCache(); + pandora.api.get({ + id: item, + keys: ['rendered'] + }, function(result) { + delete pandora.$ui.updateStatus[item]; + if (isActive()) { + if (result.data.rendered) { + Ox.Request.clearCache(); + if (pandora.isVideoView()) { + pandora.$ui.mainPanel.replaceElement(1, + pandora.$ui.rightPanel = pandora.ui.rightPanel()); + } else if(pandora.$ui.item) { + pandora.updateItemContext(); + pandora.$ui.item.reload(); + } + } else { + pandora.updateStatus(item); + } + } + }); + } else { + delete pandora.$ui.updateStatus[item]; + } + }, 10000); + + function isActive() { + return ui.item == item && [ + 'info', 'player', 'editor', 'timeline' + ].indexOf(ui.itemView) > -1; + } +}; + pandora.wait = function(taskId, callback, timeout) { var task = {}; timeout = timeout || 5000;