"Fix dirty hack" (runtime.reload) in chromium.js
Runtime reload is overkill and causes a jarring ux. Instead, send and receive messages across the runtime. Also, if we need to jump between the main ui and options pages, simply navigate within the current tab rather than spawning a new one.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
;(function() {
|
||||
'use strict';
|
||||
|
||||
function init() {
|
||||
if (!localStorage.getItem('first_install_ran')) {
|
||||
localStorage.setItem('first_install_ran', 1);
|
||||
extension.navigator.tabs.create("options.html");
|
||||
@@ -33,4 +34,8 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
addRegistrationListener(init);
|
||||
init();
|
||||
})();
|
||||
|
@@ -36,10 +36,18 @@ window.extension.navigator = function() {
|
||||
|
||||
function registrationDone() {
|
||||
localStorage.setItem("chromiumRegistrationDone", "");
|
||||
//TODO: Fix dirty hack:
|
||||
chrome.runtime.reload();
|
||||
chrome.runtime.sendMessage('registration_done');
|
||||
window.location = '/index.html';
|
||||
}
|
||||
|
||||
function isRegistrationDone() {
|
||||
return localStorage.getItem("chromiumRegistrationDone") !== null;
|
||||
}
|
||||
|
||||
function addRegistrationListener(callback) {
|
||||
chrome.runtime.onMessage.addListener(function(message) {
|
||||
if (message === 'registration_done') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@@ -63,7 +63,7 @@ Whisper.Layout = new (Backbone.View.extend({
|
||||
}))({el: document});
|
||||
|
||||
if (textsecure.storage.getUnencrypted("number_id") === undefined) {
|
||||
extension.navigator.tabs.create("options.html");
|
||||
window.location = '/options.html';
|
||||
} else {
|
||||
textsecure.storage.putUnencrypted("unreadCount", 0);
|
||||
extension.navigator.setBadgeText("");
|
||||
|
Reference in New Issue
Block a user