1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-23 09:22:23 -05:00

show loading or decrypting state in reader

This commit is contained in:
Tankred Hase 2014-02-21 16:22:33 +01:00
parent 179896ddfe
commit 0ca5ba07ad
4 changed files with 77 additions and 15 deletions

View File

@ -67,7 +67,22 @@ define(function(require) {
emailDao.getBody({ emailDao.getBody({
folder: getFolder().path, folder: getFolder().path,
message: email message: email
}, function(err) {
if (err) {
$scope.onError(err);
return;
}
// display fetched body
$scope.$apply();
// automatically decrypt if it's the selected email
if (email === $scope.state.mailList.selected) {
emailDao.decryptMessageContent({
message: email
}, $scope.onError); }, $scope.onError);
}
});
}; };
/** /**
@ -115,7 +130,7 @@ define(function(require) {
// if we're in the outbox, don't do an imap sync // if we're in the outbox, don't do an imap sync
if (getFolder().type === 'Outbox') { if (getFolder().type === 'Outbox') {
updateStatus('Last update: ', new Date()); updateStatus('Last update: ', new Date());
displayEmails(outboxBo.pendingEmails); selectFirstMessage(outboxBo.pendingEmails);
return; return;
} }
@ -144,7 +159,7 @@ define(function(require) {
} }
// sort emails // sort emails
displayEmails(getFolder().messages); selectFirstMessage(getFolder().messages);
// display last update // display last update
updateStatus('Last update: ', new Date()); updateStatus('Last update: ', new Date());
$scope.$apply(); $scope.$apply();
@ -221,7 +236,7 @@ define(function(require) {
if (!window.chrome || !chrome.identity) { if (!window.chrome || !chrome.identity) {
updateStatus('Last update: ', new Date()); updateStatus('Last update: ', new Date());
getFolder().messages = createDummyMails(); getFolder().messages = createDummyMails();
displayEmails(getFolder().messages); selectFirstMessage(getFolder().messages);
return; return;
} }
@ -230,11 +245,14 @@ define(function(require) {
// if we're in the outbox, read directly from there. // if we're in the outbox, read directly from there.
if (getFolder().type === 'Outbox') { if (getFolder().type === 'Outbox') {
updateStatus('Last update: ', new Date()); updateStatus('Last update: ', new Date());
displayEmails(outboxBo.pendingEmails); selectFirstMessage(outboxBo.pendingEmails);
return; return;
} }
displayEmails(getFolder().messages); // unselect selection from old folder
$scope.select();
// display and select first
selectFirstMessage(getFolder().messages);
$scope.synchronize(); $scope.synchronize();
}); });
@ -268,7 +286,7 @@ define(function(require) {
$scope.lastUpdate = (time) ? time : ''; $scope.lastUpdate = (time) ? time : '';
} }
function displayEmails(emails) { function selectFirstMessage(emails) {
if (!emails || emails.length < 1) { if (!emails || emails.length < 1) {
$scope.select(); $scope.select();
return; return;
@ -390,6 +408,7 @@ define(function(require) {
this.subject = 'Getting started'; // Subject line this.subject = 'Getting started'; // Subject line
this.body = 'Here are a few pointers to help you get started with Whiteout Mail.\n\n# Write encrypted message\n- You can compose a message by clicking on the compose button on the upper right (keyboard shortcut is "n" for a new message or "r" to reply).\n- When typing the recipient\'s email address, secure recipients are marked with a blue label and insecure recipients are red.\n- When sending an email to insecure recipients, the default behavior for Whiteout Mail is to invite them to the service and only send the message content in an encrypted form, once they have joined.\n\n# Advanced features\n- To verify a recipient\'s PGP key, you can hover over the blue label containing their email address and their key fingerprint will be displayed.\n- To view your own key fingerprint, open the account view in the navigation bar on the left. You can compare these with your correspondants over a second channel such as a phonecall.\n\nWe hope this helped you to get started with Whiteout Mail.\n\nYour Whiteout Networks team'; // plaintext body this.body = 'Here are a few pointers to help you get started with Whiteout Mail.\n\n# Write encrypted message\n- You can compose a message by clicking on the compose button on the upper right (keyboard shortcut is "n" for a new message or "r" to reply).\n- When typing the recipient\'s email address, secure recipients are marked with a blue label and insecure recipients are red.\n- When sending an email to insecure recipients, the default behavior for Whiteout Mail is to invite them to the service and only send the message content in an encrypted form, once they have joined.\n\n# Advanced features\n- To verify a recipient\'s PGP key, you can hover over the blue label containing their email address and their key fingerprint will be displayed.\n- To view your own key fingerprint, open the account view in the navigation bar on the left. You can compare these with your correspondants over a second channel such as a phonecall.\n\nWe hope this helped you to get started with Whiteout Mail.\n\nYour Whiteout Networks team'; // plaintext body
this.encrypted = true; this.encrypted = true;
this.decrypted = true;
}; };
var dummys = [new Email(true, true), new Email(true, false, true, true), new Email(false, true, true), new Email(false, true), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false)]; var dummys = [new Email(true, true), new Email(true, false, true, true), new Email(false, true, true), new Email(false, true), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false), new Email(false)];

View File

@ -6,6 +6,7 @@ define(function() {
er.attachHandler = function(scope) { er.attachHandler = function(scope) {
scope.$root.onError = function(options) { scope.$root.onError = function(options) {
if (!options) { if (!options) {
scope.$apply();
return; return;
} }

View File

@ -85,6 +85,43 @@
height: 100%; height: 100%;
overflow-y: scroll; overflow-y: scroll;
.working {
margin: 0 auto;
height: 100%;
width: 230px;
display: table;
.container {
display: table-cell;
vertical-align: middle;
.spinner {
position: relative;
div {
position: absolute;
top: 0;
left: 0;
height: 30px;
width: 30px;
animation: rotation .6s linear infinite;
border-left: 5px solid $color-grey-light;
border-right: 5px solid $color-grey-light;
border-bottom: 5px solid $color-grey-light;
border-top: 5px solid $color-grey;
border-radius: 100%;
}
}
h1 {
margin: 0;
padding-left: 40px;
line-height: 30px;
color: $color-grey-input;
}
}
}
.line { .line {
word-wrap: break-word; word-wrap: break-word;

View File

@ -35,14 +35,19 @@
</div> </div>
</div><!--/.ng-switch--> </div><!--/.ng-switch-->
<div class="body" ng-switch="state.mailList.selected.encrypted === false || (state.mailList.selected.encrypted === true && state.mailList.selected.decrypted === true)">
<div class="body" ng-switch="state.mailList.selected.encrypted === true && state.mailList.selected.decrypted === false"> <div ng-switch-when="true">
<div class="line">
<div ng-switch-when="true">This message contains encrypted content.</div>
<div ng-switch-default>
<!-- Render lines of a text-email in divs for easier styling --> <!-- Render lines of a text-email in divs for easier styling -->
<div ng-repeat="line in state.mailList.selected.body.split('\n') track by $index" ng-class="{'empty-line': lineEmpty(line)}">{{line}}<br></div> <div class="line" ng-repeat="line in state.mailList.selected.body.split('\n') track by $index" ng-class="{'empty-line': lineEmpty(line)}">{{line}}<br></div>
</div> </div>
<div class="working" ng-switch-default>
<div class="container">
<div class="spinner"><div></div></div>
<span ng-switch="state.mailList.selected.loadingBody === true || state.mailList.selected.body === undefined || state.mailList.selected.body === null">
<h1 ng-switch-when="true">Loading...</h1>
<h1 ng-switch-default>Decrypting...</h1>
</span>
</div><!--/.container-->
</div> </div>
</div><!--/.body--> </div><!--/.body-->