trigger transfer progress -1 if download is canceled

This commit is contained in:
j 2016-01-17 16:51:06 +05:30
parent c6c032d3d9
commit 1266fb9133
2 changed files with 12 additions and 4 deletions

View file

@ -325,6 +325,9 @@ def cancelDownloads(data):
for l in item.lists.filter_by(user_id=settings.USER_ID): for l in item.lists.filter_by(user_id=settings.USER_ID):
l.items.remove(item) l.items.remove(item)
item.update() item.update()
trigger_event('transfer', {
'id': item.id, 'progress': -1
})
response = {'cancelled': ids} response = {'cancelled': ids}
return response return response
actions.register(cancelDownloads, cache=False) actions.register(cancelDownloads, cache=False)

View file

@ -55,13 +55,18 @@ oml.ui.appPanel = function() {
oml.bindEvent({ oml.bindEvent({
transfer: Ox.throttle(function(data) { transfer: Ox.throttle(function(data) {
var mediastate = data.progress < -1
? 'unavailable'
: data.progress < 1
? 'transferring'
: 'available';
oml.$ui.list.value(data.id, { oml.$ui.list.value(data.id, {
mediastate: data.progress < 1 ? 'transferring' : 'available' mediastate: mediastate
}); });
oml.$ui.browser.value(data.id, { oml.$ui.browser.value(data.id, {
mediastate: data.progress < 1 ? 'transferring' : 'available' mediastate: mediastate
}); });
if (data.progress == 1 && data.id == ui.item) { if ((data.progress == 1 || data.progress == -1) && data.id == ui.item) {
Ox.Request.clearCache(); Ox.Request.clearCache();
oml.$ui.infoView.updateElement(ui.item); oml.$ui.infoView.updateElement(ui.item);
} }
@ -79,4 +84,4 @@ oml.ui.appPanel = function() {
return that; return that;
}; };