From 4019c0cf77c43e1caf7abed0fc373dd53ba2d6b0 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 21 Oct 2017 14:43:56 +0200 Subject: [PATCH] Improvement: Use backgroundpage for data if possible --- src/js/dial.js | 16 ++++++++++++++-- src/manifest.json | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/js/dial.js b/src/js/dial.js index ef41db3..9592e69 100644 --- a/src/js/dial.js +++ b/src/js/dial.js @@ -79,10 +79,22 @@ app.Messages.init = function(){ }); }; app.Messages.getSettings = function(callback){ - browser.runtime.sendMessage({ cmd: app.Messages.Commands.getSettings }).then(callback, callback); + browser.runtime.getBackgroundPage().then(function(page){ + if(page){ + if(callback) callback(page.app.settings); + } else { + browser.runtime.sendMessage({ cmd: app.Messages.Commands.getSettings }).then(callback, callback); + } + }); }; app.Messages.getNode = function(path, callback){ - browser.runtime.sendMessage({ cmd: app.Messages.Commands.getNode, path: path }).then(callback); + browser.runtime.getBackgroundPage().then(function(page){ + if(page){ + if(callback) callback(page.app.GridNodes.getNode(page.app.node, dial.path.substr(1))); + } else { + browser.runtime.sendMessage({ cmd: app.Messages.Commands.getNode, path: path }).then(callback); + } + }); }; app.Messages.setNodeIndex = function(index, newIndex, callback){ browser.runtime.sendMessage({ cmd: app.Messages.Commands.setNodeIndex, path: dial.path, index: index, newIndex: newIndex }).then(callback); diff --git a/src/manifest.json b/src/manifest.json index 52a17e9..785cdfc 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Quick Dial", - "version": "0.1.4", + "version": "0.1.4", "author": "MatMoul", "homepage_url": "https://github.com/MatMoul/quickdial-webext", "developer": {