Make getBackground async
This commit is contained in:
parent
a57363f1c0
commit
76e170686a
6 changed files with 198 additions and 175 deletions
|
@ -72,8 +72,18 @@
|
|||
chrome.windows.remove(windowId);
|
||||
},
|
||||
|
||||
getBackground: function() {
|
||||
return chrome.extension.getBackgroundPage();
|
||||
getBackground: function(callback) {
|
||||
if (chrome.extension) {
|
||||
return new Promise(function(resolve) {
|
||||
callback(chrome.extension.getBackgroundPage());
|
||||
resolve();
|
||||
});
|
||||
} else if (chrome.runtime) {
|
||||
return new Promise(function(resolve) {
|
||||
chrome.runtime.getBackgroundPage(callback);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
getViews: function() {
|
||||
|
@ -96,4 +106,11 @@
|
|||
return localStorage.getItem("chromiumRegistrationDone") !== null;
|
||||
},
|
||||
};
|
||||
|
||||
chrome.app.runtime.onLaunched.addListener(function() {
|
||||
chrome.app.window.create('index.html', {
|
||||
id: 'main',
|
||||
bounds: { width: 620, height: 500 }
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
window.Whisper = window.Whisper || {};
|
||||
|
||||
extension.windows.getCurrent(function (windowInfo) {
|
||||
var bg = extension.windows.getBackground();
|
||||
extension.windows.getBackground(function(bg) {
|
||||
window.$ = bg.$;
|
||||
var body = $('body', document);
|
||||
var conversation = bg.getConversationForWindow(windowInfo.id);
|
||||
|
@ -35,4 +35,5 @@
|
|||
$('<div>').text('Error').prependTo(body);
|
||||
}
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -16,12 +16,14 @@
|
|||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
var bg = extension.windows.getBackground();
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
extension.windows.getBackground(function(bg) {
|
||||
if (bg.textsecure.storage.user.getNumber() === undefined) {
|
||||
window.location = '/options.html';
|
||||
} else {
|
||||
new bg.Whisper.InboxView().$el.prependTo(bg.$('body',document));
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
});
|
||||
|
||||
$(function() {
|
||||
var bg = extension.windows.getBackground();
|
||||
extension.windows.getBackground(function(bg) {
|
||||
if (bg.textsecure.registration.isDone()) {
|
||||
$('#complete-number').text(bg.textsecure.storage.user.getNumber());
|
||||
$('#setup-complete').show().addClass('in');
|
||||
|
@ -87,4 +87,5 @@
|
|||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
;(function() {
|
||||
'use strict';
|
||||
var bg = extension.windows.getBackground();
|
||||
extension.windows.getBackground(function(bg) {
|
||||
var accountManager = new bg.textsecure.AccountManager();
|
||||
|
||||
function log(s) {
|
||||
|
@ -94,5 +94,6 @@
|
|||
log(e);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
'use strict';
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
var bg = extension.windows.getBackground();
|
||||
|
||||
extension.windows.getBackground(function(bg) {
|
||||
var SocketView = Whisper.View.extend({
|
||||
className: 'status',
|
||||
initialize: function() {
|
||||
|
@ -98,5 +98,6 @@
|
|||
this.$el.show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue