Changed message object

This commit is contained in:
Scott Pigeon 2015-02-21 11:23:33 -05:00
parent 2e238e25f3
commit 1506c74b57

View file

@ -2,19 +2,18 @@ define([
"command",
"settings!api"
], function(command, Settings) {
//handles sending custom messages based on Caret commands (builds, plugins, etc)
var targets = Settings.get("api");
command.on("init:restart", function() {
targets = Settings.get("api");
});
command.on("api:execute", function(id, c) {
if (!id in targets) return c();
var config = targets[id];
var message = Object.create(config.message);
var send = function() {
chrome.runtime.sendMessage(config.id, message, null, function() {
chrome.runtime.sendMessage(config.id, config.message, null, function() {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError);
}
@ -35,7 +34,7 @@ define([
send();
}
});
//External apps can send messages by matching Caret's command/argument config objects
chrome.runtime.onMessageExternal.addListener(function(message, sender, c) {
command.fire(message.command, message.argument, c);