From dc32f7eeb133b4854c01659bf4fb155de8a34767 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 19 Nov 2015 13:38:23 +0100 Subject: [PATCH] Remove legacy hacks and add useful error --- data/js/tomahawk.js | 47 +++------------------------------------------ 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/data/js/tomahawk.js b/data/js/tomahawk.js index bac76c878..0f15d54fc 100644 --- a/data/js/tomahawk.js +++ b/data/js/tomahawk.js @@ -812,52 +812,11 @@ Tomahawk.PluginManager = { } } - if (typeof this.objects[objectId][methodName] === 'function') { - if (!Tomahawk.resolver.instance.apiVersion - || Tomahawk.resolver.instance.apiVersion < 0.9) { - if (methodName == 'artists') { - return new RSVP.Promise(function (resolve, reject) { - pluginManager.resolve[requestId] = resolve; - Tomahawk.resolver.instance.artists(requestId); - }); - } else if (methodName == 'albums') { - return new RSVP.Promise(function (resolve, reject) { - pluginManager.resolve[requestId] = resolve; - Tomahawk.resolver.instance.albums(requestId, params.artist); - }); - } else if (methodName == 'tracks') { - return new RSVP.Promise(function (resolve, reject) { - pluginManager.resolve[requestId] = resolve; - Tomahawk.resolver.instance.tracks(requestId, params.artist, params.album); - }); - } else if (methodName == 'lookupUrl') { - return new RSVP.Promise(function (resolve, reject) { - pluginManager.resolve[params.url] = resolve; - Tomahawk.resolver.instance.lookupUrl(params.url); - }); - } else if (methodName == 'getStreamUrl') { - return new RSVP.Promise(function (resolve, reject) { - pluginManager.resolve[requestId] = resolve; - Tomahawk.resolver.instance.getStreamUrl(requestId, params.url); - }); - } else if (methodName == 'resolve') { - return new RSVP.Promise(function (resolve, reject) { - pluginManager.resolve[requestId] = resolve; - Tomahawk.resolver.instance.resolve(requestId, params.artist, - params.album, params.track); - }); - } else if (methodName == 'search') { - return new RSVP.Promise(function (resolve, reject) { - pluginManager.resolve[requestId] = resolve; - Tomahawk.resolver.instance.search(requestId, params.query); - }); - } - } - - return this.objects[objectId][methodName](params); + if (typeof this.objects[objectId][methodName] !== 'function') { + throw new Error('\'' + methodName + '\' on ScriptObject ' + objectId + ' is not a function', typeof this.objects[objectId][methodName]); } - return this.objects[objectId][methodName]; + return this.objects[objectId][methodName](params); }, invoke: function (requestId, objectId, methodName, params) {