index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*global $, Whisper, Backbone, textsecure, extension*/
  2. /*
  3. * vim: ts=4:sw=4:expandtab
  4. */
  5. (function () {
  6. 'use strict';
  7. function logError(error) {
  8. extension.windows.getBackground(function(bg) {
  9. bg.console.log('index.html: ', error);
  10. });
  11. }
  12. window.onerror = function(message, script, line, col, error) {
  13. logError(error);
  14. };
  15. var view;
  16. function render() {
  17. extension.windows.getBackground(function(bg) {
  18. bg.ConversationController.updateInbox().then(function() {
  19. try {
  20. if (view) { view.remove(); }
  21. var $body = bg.$('body',document).empty();
  22. view = new bg.Whisper.InboxView({window: window});
  23. view.$el.prependTo($body);
  24. window.openConversation = function(conversation) {
  25. if (conversation) {
  26. view.openConversation(null, conversation);
  27. }
  28. };
  29. openConversation(bg.getOpenConversation());
  30. } catch (e) {
  31. logError(e);
  32. }
  33. });
  34. });
  35. }
  36. window.addEventListener('onreload', render);
  37. render();
  38. }());