Refactor index.js

There is no in-window navigation in the chrome app environment, so nix
the first if-clause here. Also make it programmatically reloadable and
fix indentation.

// FREEBIE
pull/749/head
lilia 10 years ago
parent 2bdd0106e7
commit f9ce27f2c8

@ -3,17 +3,17 @@
* vim: ts=4:sw=4:expandtab * vim: ts=4:sw=4:expandtab
*/ */
(function () { (function () {
'use strict'; 'use strict';
window.Whisper = window.Whisper || {}; var view;
extension.windows.getBackground(function(bg) { function render() {
if (bg.textsecure.storage.user.getNumber() === undefined) { extension.windows.getBackground(function(bg) {
window.location = '/options.html';
} else {
extension.windows.getCurrent(function(appWindow) { extension.windows.getCurrent(function(appWindow) {
var view = new bg.Whisper.InboxView({appWindow: appWindow}); if (view) { view.remove(); }
view.$el.prependTo(bg.$('body',document)); var $body = bg.$('body',document).empty();
view = new bg.Whisper.InboxView({appWindow: appWindow});
view.$el.prependTo($body);
window.openConversation = function(conversation) { window.openConversation = function(conversation) {
if (conversation) { if (conversation) {
view.openConversation(null, conversation); view.openConversation(null, conversation);
@ -21,6 +21,9 @@
}; };
openConversation(bg.getOpenConversation()); openConversation(bg.getOpenConversation());
}); });
} });
}); }
window.addEventListener('onreload', render);
render();
}()); }());

Loading…
Cancel
Save