Move function declarations out of storage.onready
This commit is contained in:
parent
c8e51563a0
commit
3bf9e36ead
1 changed files with 191 additions and 192 deletions
|
@ -30,19 +30,8 @@
|
|||
});
|
||||
});
|
||||
|
||||
storage.fetch();
|
||||
storage.onready(function() {
|
||||
var SERVER_URL = 'https://textsecure-service-staging.whispersystems.org';
|
||||
var messageReceiver;
|
||||
|
||||
if (textsecure.registration.isDone()) {
|
||||
init();
|
||||
}
|
||||
extension.on('registration_done', function() {
|
||||
init(true);
|
||||
});
|
||||
|
||||
setUnreadCount(storage.get("unreadCount", 0));
|
||||
|
||||
window.getSocketStatus = function() {
|
||||
if (messageReceiver) {
|
||||
return messageReceiver.getStatus();
|
||||
|
@ -50,10 +39,22 @@
|
|||
return -1;
|
||||
}
|
||||
};
|
||||
storage.fetch();
|
||||
storage.onready(function() {
|
||||
setUnreadCount(storage.get("unreadCount", 0));
|
||||
|
||||
if (textsecure.registration.isDone()) {
|
||||
init();
|
||||
}
|
||||
|
||||
extension.on('registration_done', function() {
|
||||
init(true);
|
||||
});
|
||||
|
||||
if (open) {
|
||||
openInbox();
|
||||
}
|
||||
});
|
||||
|
||||
function init(firstRun) {
|
||||
window.removeEventListener('online', init);
|
||||
|
@ -61,13 +62,12 @@
|
|||
|
||||
if (messageReceiver) { messageReceiver.close(); }
|
||||
|
||||
var URL = 'https://textsecure-service-staging.whispersystems.org';
|
||||
var USERNAME = storage.get('number_id');
|
||||
var PASSWORD = storage.get('password');
|
||||
var mySignalingKey = storage.get('signaling_key');
|
||||
|
||||
// initialize the socket and start listening for messages
|
||||
messageReceiver = new textsecure.MessageReceiver(URL, USERNAME, PASSWORD, mySignalingKey);
|
||||
messageReceiver = new textsecure.MessageReceiver(SERVER_URL, USERNAME, PASSWORD, mySignalingKey);
|
||||
messageReceiver.addEventListener('message', onMessageReceived);
|
||||
messageReceiver.addEventListener('receipt', onDeliveryReceipt);
|
||||
messageReceiver.addEventListener('contact', onContactReceived);
|
||||
|
@ -235,5 +235,4 @@
|
|||
console.log('got delivery receipt for unknown message', pushMessage.source, timestamp);
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue