Namespace registration helpers
This commit is contained in:
parent
28290477f4
commit
5a0e199fc5
3 changed files with 23 additions and 20 deletions
|
@ -22,7 +22,7 @@
|
|||
localStorage.setItem('first_install_ran', 1);
|
||||
extension.navigator.tabs.create("options.html");
|
||||
} else {
|
||||
if (isRegistrationDone()) {
|
||||
if (textsecure.registration.isDone()) {
|
||||
textsecure.subscribeToPush(function(message) {
|
||||
Whisper.Messages.addIncomingMessage(message).then(function() {
|
||||
console.log("Got message from " + message.pushMessage.source + "." + message.pushMessage.sourceDevice +
|
||||
|
@ -36,6 +36,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
addRegistrationListener(init);
|
||||
textsecure.registration.addListener(init);
|
||||
init();
|
||||
})();
|
||||
|
|
|
@ -35,21 +35,24 @@
|
|||
|
||||
// Random shared utilities that are used only by chromium things
|
||||
|
||||
function registrationDone() {
|
||||
localStorage.setItem("chromiumRegistrationDone", "");
|
||||
chrome.runtime.sendMessage('registration_done');
|
||||
window.location = '/index.html';
|
||||
}
|
||||
window.textsecure = window.textsecure || {};
|
||||
window.textsecure.registration = {
|
||||
done: function () {
|
||||
localStorage.setItem("chromiumRegistrationDone", "");
|
||||
chrome.runtime.sendMessage('registration_done');
|
||||
window.location = '/index.html';
|
||||
},
|
||||
|
||||
function isRegistrationDone() {
|
||||
return localStorage.getItem("chromiumRegistrationDone") !== null;
|
||||
}
|
||||
isDone: function () {
|
||||
return localStorage.getItem("chromiumRegistrationDone") !== null;
|
||||
},
|
||||
|
||||
function addRegistrationListener(callback) {
|
||||
chrome.runtime.onMessage.addListener(function(message) {
|
||||
if (message === 'registration_done') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
addListener: function (callback) {
|
||||
chrome.runtime.onMessage.addListener(function(message) {
|
||||
if (message === 'registration_done') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
};
|
||||
|
||||
$(function() {
|
||||
if (isRegistrationDone()) {
|
||||
if (textsecure.registration.isDone()) {
|
||||
$('#complete-number').text(textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0]);//TODO: no
|
||||
$('#setup-complete').show().addClass('in');
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@
|
|||
$('#verify').hide();
|
||||
$('#init-setup').hide().removeClass('in');
|
||||
$('#setup-complete').show().addClass('in');
|
||||
registrationDone();
|
||||
textsecure.registration.done();
|
||||
}
|
||||
}).catch(function(error) {
|
||||
$('#verify *').hide();
|
||||
|
@ -192,7 +192,7 @@
|
|||
case 5:
|
||||
$('#verify').hide();
|
||||
$('#setup-complete').show().addClass('in');
|
||||
registrationDone();
|
||||
textsecure.registration.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue