From 1266fb913382d77dce5b31ba11a3235bd736d86a Mon Sep 17 00:00:00 2001 From: j Date: Sun, 17 Jan 2016 16:51:06 +0530 Subject: [PATCH] trigger transfer progress -1 if download is canceled --- oml/item/api.py | 3 +++ static/js/appPanel.js | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/oml/item/api.py b/oml/item/api.py index da4507c..0da8a2b 100644 --- a/oml/item/api.py +++ b/oml/item/api.py @@ -325,6 +325,9 @@ def cancelDownloads(data): for l in item.lists.filter_by(user_id=settings.USER_ID): l.items.remove(item) item.update() + trigger_event('transfer', { + 'id': item.id, 'progress': -1 + }) response = {'cancelled': ids} return response actions.register(cancelDownloads, cache=False) diff --git a/static/js/appPanel.js b/static/js/appPanel.js index 2569900..2742708 100644 --- a/static/js/appPanel.js +++ b/static/js/appPanel.js @@ -55,13 +55,18 @@ oml.ui.appPanel = function() { oml.bindEvent({ transfer: Ox.throttle(function(data) { + var mediastate = data.progress < -1 + ? 'unavailable' + : data.progress < 1 + ? 'transferring' + : 'available'; oml.$ui.list.value(data.id, { - mediastate: data.progress < 1 ? 'transferring' : 'available' + mediastate: mediastate }); 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(); oml.$ui.infoView.updateElement(ui.item); } @@ -79,4 +84,4 @@ oml.ui.appPanel = function() { return that; -}; \ No newline at end of file +};