Cable-Desktop/js/index.js
lilia 7fb4d3d8aa Load all inbox convos before rendering
This is a better alternative to the fix in 0434c4b, which causes
problems when creating a new conversation from entering a phone number.

// FREEBIE
2016-03-17 20:58:56 -07:00

45 lines
1.4 KiB
JavaScript

/*global $, Whisper, Backbone, textsecure, extension*/
/*
* vim: ts=4:sw=4:expandtab
*/
(function () {
'use strict';
function logError(error) {
extension.windows.getBackground(function(bg) {
bg.console.log('index.html: ', error);
});
}
window.onerror = function(message, script, line, col, error) {
logError(error);
};
var view;
function render() {
extension.windows.getBackground(function(bg) {
extension.windows.getCurrent(function(appWindow) {
bg.ConversationController.updateInbox().then(function() {
try {
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);
}
};
openConversation(bg.getOpenConversation());
} catch (e) {
logError(e);
}
});
});
});
}
window.addEventListener('onreload', render);
render();
}());