check if encoding status changed, fixes #1599

This commit is contained in:
j 2014-04-05 17:17:26 +00:00
parent e4e7fb87b1
commit 334985affe

View file

@ -246,7 +246,6 @@ pandora.ui.mediaView = function(options) {
click: function(data) { click: function(data) {
if (data.key == 'selected') { if (data.key == 'selected') {
var value = self.$filesList.value(data.id); var value = self.$filesList.value(data.id);
console.log(data, value);
if (value.state == 'failed') { if (value.state == 'failed') {
var $dialog = Ox.Dialog({ var $dialog = Ox.Dialog({
buttons: [ buttons: [
@ -305,6 +304,7 @@ pandora.ui.mediaView = function(options) {
}, },
init: function(data) { init: function(data) {
self.numberOfItems = data.items; self.numberOfItems = data.items;
updateStatus();
}, },
select: selectFiles, select: selectFiles,
submit: function(data) { submit: function(data) {
@ -515,6 +515,11 @@ pandora.ui.mediaView = function(options) {
}); });
} }
function isActive() {
return pandora.user.ui.item == options.id
&& pandora.user.ui.itemView == 'media';
}
function moveFiles(data) { function moveFiles(data) {
var data = { var data = {
ids: self.selected, ids: self.selected,
@ -527,10 +532,7 @@ pandora.ui.mediaView = function(options) {
{disabled: true, title: Ox._('Moving Files...')} {disabled: true, title: Ox._('Moving Files...')}
); );
pandora.api.moveMedia(data, function(result) { pandora.api.moveMedia(data, function(result) {
if ( if (isActive()) {
pandora.user.ui.item == options.id
&& pandora.user.ui.itemView == 'media'
) {
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
if (self.$switch.value()) { if (self.$switch.value()) {
pandora.UI.set({item: result.data.item}); pandora.UI.set({item: result.data.item});
@ -618,6 +620,42 @@ pandora.ui.mediaView = function(options) {
]('ignore'); ]('ignore');
} }
function updateStatus() {
if (self.numberOfItems) {
setTimeout(function() {
if (isActive() && self.numberOfItems) {
Ox.Request.clearCache();
pandora.api.findMedia({
query: self.filesQuery,
range: [0, self.numberOfItems],
keys: ['id', 'state']
}, function(result) {
if (isActive()) {
var done = false,
update = false;
result.data.items.forEach(function(item) {
if (self.$filesList.value(item.id, 'state') == 'encoding'
&& item.state != 'encoding') {
done = true;
}
self.$filesList.value(item.id, 'state', item.state);
if (!update && item.state == 'encoding') {
update = true;
}
});
if (update) {
updateStatus();
} else if (done) {
Ox.Request.clearCache();
pandora.updateItemContext();
}
}
});
}
}, 10000);
}
}
that.reload = function() { that.reload = function() {
self.$filesList.reloadList(); self.$filesList.reloadList();
} }