[chrome-gnome-shell] Move all initialization code to SweetTooth.initialize.
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chrome-gnome-shell] Move all initialization code to SweetTooth.initialize.
- Date: Sat, 19 Nov 2016 09:37:23 +0000 (UTC)
commit 6425fdf4aab71392ccc7cb1619b1fe903bf4a1e7
Author: Yuri Konotopov <ykonotopov gmail com>
Date: Sat Nov 19 12:34:53 2016 +0300
Move all initialization code to SweetTooth.initialize.
extension/include/sweettooth-api.js | 70 ++++++++++++++++++----------------
1 files changed, 37 insertions(+), 33 deletions(-)
---
diff --git a/extension/include/sweettooth-api.js b/extension/include/sweettooth-api.js
index c423cf4..d66c0c2 100644
--- a/extension/include/sweettooth-api.js
+++ b/extension/include/sweettooth-api.js
@@ -65,21 +65,47 @@ define('gs-chrome', ['jquery'], function($) {
return sendResolveExtensionMessage("uninstallExtension", "success", {uuid:
uuid});
},
- initialize: function(done, fail, always) {
+ initialize: function() {
var ready = $.Deferred();
- if(done)
- {
- ready.done(done);
- }
- if(fail)
+
+ if(SweetTooth.shellVersion !== '-1')
{
- ready.fail(fail);
+ ready.resolve();
}
- if(always)
+ else
{
- ready.always(always);
+ require(['jquery', 'messages'], function($, messages) {
+ var connectingInfo = GSC.getMessage('connecting_host_app');
+ messages.addInfo(connectingInfo);
+
+ ready.done(function(response) {
+ apiObject.shellVersion =
response.shellVersion;
+ apiObject.versionValidationEnabled =
response.versionValidationEnabled;
+
+ if(!response.connectorVersion ||
response.connectorVersion != GS_CHROME_VERSION)
+ {
+ if(!response.connectorVersion)
+ response.connectorVersion =
GSC.getMessage('older_connector');
+ else
+ response.connectorVersion =
GSC.getMessage('version', response.connectorVersion);
+
+
messages.addWarning(GSC.getMessage('warning_versions_mismatch', GSC.getMessage('version', GS_CHROME_VERSION),
response.connectorVersion));
+ }
+
+ $('#message_container')
+ .find('.message:contains("' + connectingInfo
+ '")')
+ .remove();
+ });
+
+ ready.fail(function(message) {
+ messages.addWarning(message ? message :
GSC.getMessage('no_host_connector'));
+ });
+
+ sendResolveExtensionMessage("initialize", "properties", null,
ready);
+ });
}
- sendResolveExtensionMessage("initialize", "properties", null, ready);
+
+ return ready;
}
};
@@ -160,29 +186,7 @@ requirejs.config({
waitSeconds: 15 // It's fails sometimes with default 7 secs
});
require(['jquery', 'messages', 'gs-chrome'], function($, messages){
- var connectingInfo = GSC.getMessage('connecting_host_app');
- messages.addInfo(connectingInfo);
-
- SweetTooth.initialize(function(response) {
- SweetTooth.shellVersion = response.shellVersion;
- SweetTooth.versionValidationEnabled = response.versionValidationEnabled;
-
- if(!response.connectorVersion || response.connectorVersion != GS_CHROME_VERSION)
- {
- if(!response.connectorVersion)
- response.connectorVersion = GSC.getMessage('older_connector');
- else
- response.connectorVersion = GSC.getMessage('version',
response.connectorVersion);
-
- messages.addWarning(GSC.getMessage('warning_versions_mismatch',
GSC.getMessage('version', GS_CHROME_VERSION), response.connectorVersion));
- }
-
- $('#message_container')
- .find('.message:contains("' + connectingInfo + '")')
- .remove();
- }, function(message) {
- messages.addWarning(message ? message : GSC.getMessage('no_host_connector'));
- }, function() {
+ SweetTooth.initialize().always(function() {
// Start extensions.gnome.org main script
require(['main'], function(){});
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]