Abstract nativeclient callback logic

The nativeclient.js module overrides
window.textsecure.registerOnLoadFunction with its own version. Otherwise
helpers will define a trivial placeholder for same.

The flag textsecure.NATIVE_CLIENT can be set anywhere ahead of
nativeclient.js, but is only acted on in nativeclient.js,
and crypto.js.
This commit is contained in:
lilia 2014-11-06 17:01:56 -08:00
parent 69c52d51b3
commit 0a3c03025b
2 changed files with 8 additions and 15 deletions

View file

@ -205,21 +205,9 @@ window.textsecure.throwHumanError = function(error, type, humanError) {
throw e;
}
;(function() {
'use strict';
window.textsecure = window.textsecure || {};
window.textsecure.NATIVE_CLIENT = window.textsecure.NATIVE_CLIENT || true;
if (!textsecure.NATIVE_CLIENT) {
window.textsecure.registerOnLoadFunction = window.textsecure.nativeclient.registerOnLoadFunction;
} else {
window.textsecure.registerOnLoadFunction = function(func) {
return new Promise(function(resolve, reject) {
return resolve(func());
});
};
}
})();
window.textsecure.registerOnLoadFunction = textsecure.registerOnLoadFunction || function(func) {
return Promise.resolve(func());
};
window.textsecure.replay = function() {
var self = {};

View file

@ -16,6 +16,11 @@
;(function() {
'use strict';
window.textsecure = window.textsecure || {};
window.textsecure.NATIVE_CLIENT = window.textsecure.NATIVE_CLIENT || true;
if (!textsecure.NATIVE_CLIENT) {
window.textsecure.registerOnLoadFunction = window.textsecure.nativeclient.registerOnLoadFunction;
}
var naclMessageNextId = 0;
var naclMessageIdCallbackMap = {};