Skip to content
Snippets Groups Projects
Commit 5555075b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

plugin is registered on the server before plugin resgister method is called

parent 2fd6bd4c
No related branches found
No related tags found
1 merge request!221Resolve "plugin API should allow to store user data"
...@@ -51,6 +51,8 @@ Plugin.prototype.load = function () { ...@@ -51,6 +51,8 @@ Plugin.prototype.load = function () {
var options = self.getOptions(); var options = self.getOptions();
var hash; var hash;
var error = false;
var registerPromise = null;
return ServerConnector.sendRequest({ return ServerConnector.sendRequest({
url: options.url, url: options.url,
...@@ -59,9 +61,7 @@ Plugin.prototype.load = function () { ...@@ -59,9 +61,7 @@ Plugin.prototype.load = function () {
}).then(function (content) { }).then(function (content) {
hash = Functions.computeMD5(content); hash = Functions.computeMD5(content);
var pluginData = undefined; var pluginData = undefined;
var error = false;
try { try {
var registerPromise = null;
// noinspection JSUnusedLocalSymbols // noinspection JSUnusedLocalSymbols
var minervaDefine = function (pluginFunction) { var minervaDefine = function (pluginFunction) {
try { try {
...@@ -86,21 +86,22 @@ Plugin.prototype.load = function () { ...@@ -86,21 +86,22 @@ Plugin.prototype.load = function () {
error = e; error = e;
} }
}; };
content += "//# sourceURL=" + options.url;
eval(content); eval(content);
} catch (e) { } catch (e) {
error = e; error = e;
} }
if (error) {
return Promise.reject(error);
}
return registerPromise;
}).then(function () {
return ServerConnector.registerPlugin({ return ServerConnector.registerPlugin({
hash: hash, hash: hash,
url: options.url, url: options.url,
name: self.getName(), name: self.getName(),
version: self.getVersion() version: self.getVersion()
}); });
}).then(function () {
if (error) {
return Promise.reject(error);
}
return registerPromise;
}); });
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment