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:
parent
69c52d51b3
commit
0a3c03025b
2 changed files with 8 additions and 15 deletions
|
@ -205,21 +205,9 @@ window.textsecure.throwHumanError = function(error, type, humanError) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
;(function() {
|
window.textsecure.registerOnLoadFunction = textsecure.registerOnLoadFunction || function(func) {
|
||||||
'use strict';
|
return Promise.resolve(func());
|
||||||
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.replay = function() {
|
window.textsecure.replay = function() {
|
||||||
var self = {};
|
var self = {};
|
||||||
|
|
|
@ -16,6 +16,11 @@
|
||||||
;(function() {
|
;(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
window.textsecure = window.textsecure || {};
|
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 naclMessageNextId = 0;
|
||||||
var naclMessageIdCallbackMap = {};
|
var naclMessageIdCallbackMap = {};
|
||||||
|
|
Loading…
Reference in a new issue