diff --git a/src/js/controller/mail-list.js b/src/js/controller/mail-list.js index 133baaa..66a3a4c 100644 --- a/src/js/controller/mail-list.js +++ b/src/js/controller/mail-list.js @@ -15,18 +15,20 @@ define(function(require) { firstSelect = true; emailDao = appController._emailDao; + if (emailDao) { + emailDao.onIncomingMessage = function(email) { + if (email.subject.indexOf(str.subjectPrefix) === -1) { + return; + } - emailDao.onIncomingMessage = function(email) { - if (email.subject.indexOf(str.subjectPrefix) === -1) { - return; - } - - // sync - $scope.synchronize(function() { - // show notification - notificationForEmail(email); - }); - }; + // sync + $scope.synchronize(function() { + // show notification + notificationForEmail(email); + }); + }; + chrome.notifications.onClicked.addListener(notificationClicked); + } function notificationClicked(uidString) { var email, uid = parseInt(uidString, 10); @@ -43,7 +45,6 @@ define(function(require) { $scope.select(email); } } - chrome.notifications.onClicked.addListener(notificationClicked); // // scope functions @@ -55,7 +56,13 @@ define(function(require) { } // split text only emails into parts for easier rendering if (!email.html && typeof email.body === 'string') { - email.bodyDisplayParts = email.body.split('\n'); + email.bodyDisplayParts = []; + var parts = email.body.split('\n'); + parts.forEach(function(part) { + if (part.trim().length > 0) { + email.bodyDisplayParts.push(part); + } + }); } $scope.selected = email; // set selected in parent scope ro it can be displayed in the read view diff --git a/src/js/controller/write.js b/src/js/controller/write.js index 57428f9..7a2086a 100644 --- a/src/js/controller/write.js +++ b/src/js/controller/write.js @@ -6,6 +6,7 @@ define(function(require) { aes = require('cryptoLib/aes-cbc'), util = require('cryptoLib/util'), str = require('js/app-config').string, + $ = require('jquery'), emailDao; // @@ -129,9 +130,8 @@ define(function(require) { return; } - body = $scope.body; // remove generated html from body - body = parseBody(body); + body = parseBody($scope.body); email = { to: [], // list of receivers @@ -165,23 +165,12 @@ define(function(require) { }; function parseBody(body) { - function has(substr) { - return (body.indexOf(substr) !== -1); - } - while (has('
' + text + '
'; + + return $(html).text(); } // diff --git a/src/tpl/read.html b/src/tpl/read.html index 61f741b..4a30410 100644 --- a/src/tpl/read.html +++ b/src/tpl/read.html @@ -24,10 +24,6 @@ -- - {{part}} - -
+{{part}}