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
This commit is contained in:
parent
2bdd0106e7
commit
f9ce27f2c8
1 changed files with 13 additions and 10 deletions
23
js/index.js
23
js/index.js
|
@ -3,17 +3,17 @@
|
|||
* vim: ts=4:sw=4:expandtab
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
var view;
|
||||
|
||||
extension.windows.getBackground(function(bg) {
|
||||
if (bg.textsecure.storage.user.getNumber() === undefined) {
|
||||
window.location = '/options.html';
|
||||
} else {
|
||||
function render() {
|
||||
extension.windows.getBackground(function(bg) {
|
||||
extension.windows.getCurrent(function(appWindow) {
|
||||
var view = new bg.Whisper.InboxView({appWindow: appWindow});
|
||||
view.$el.prependTo(bg.$('body',document));
|
||||
if (view) { view.remove(); }
|
||||
var $body = bg.$('body',document).empty();
|
||||
view = new bg.Whisper.InboxView({appWindow: appWindow});
|
||||
view.$el.prependTo($body);
|
||||
window.openConversation = function(conversation) {
|
||||
if (conversation) {
|
||||
view.openConversation(null, conversation);
|
||||
|
@ -21,6 +21,9 @@
|
|||
};
|
||||
openConversation(bg.getOpenConversation());
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('onreload', render);
|
||||
render();
|
||||
}());
|
||||
|
|
Loading…
Reference in a new issue