message display

This commit is contained in:
Thomas Rudin 2018-12-13 10:22:18 +01:00
parent 6ef2f57a84
commit 41020e7d5c
2 changed files with 29 additions and 6 deletions

View File

@ -10,9 +10,28 @@
console.log(mail);//XXX
var timeStr = "";
if (mail.time){
var time_m = moment(mail.time * 1000);
var durationStr = moment.duration(time_m - moment()).humanize(true);
timeStr = time_m.format("YYYY-MM-DD HH:mm:ss") + " (" + durationStr + ")";
}
var body = [];
mail.body.split("\n").forEach(function(line){
body.push(line);
body.push( m("br") );
});
return [
m("div")
];
m("h2", mail.subject),
m("h5", [ "From: ", m("b", mail.sender) ]),
m("h5", [ "Sent: ", m("b", timeStr) ]),
m("div", body)
]
}
};

View File

@ -78,12 +78,16 @@ service.countUnread = function(){
service.readMail = function(index){
if (webmail.mails && webmail.mails.length){
//mark as read with api
webmail.api.markRead(index);
//mark read locally
var mail = webmail.mails[index-1];
mail.unread = false;
//mark as read with api
if (mail.unread){
webmail.api.markRead(index);
//mark read locally
mail.unread = false;
}
return mail;
}