Order notifications by creation time across all mailboxes

pull/1/head
yflory 4 years ago
parent 098011d1b2
commit 632d5db8d2

@ -299,6 +299,7 @@ proxy.mailboxes = {
sendMessage(msg, function (err, hash) {
if (err) { return void console.error(err); }
box.history.push(hash);
_msg.ctime = +new Date();
box.content[hash] = _msg;
var message = {
msg: _msg,
@ -314,9 +315,10 @@ proxy.mailboxes = {
box.queue = [];
};
var lastReceivedHash; // Don't send a duplicate of the last known hash on reconnect
box.onMessage = cfg.onMessage = function (msg, user, vKey, isCp, hash, author) {
box.onMessage = cfg.onMessage = function (msg, user, vKey, isCp, hash, author, data) {
if (hash === m.lastKnownHash) { return; }
if (hash === lastReceivedHash) { return; }
var time = data && data.time;
lastReceivedHash = hash;
try {
msg = JSON.parse(msg);
@ -362,6 +364,7 @@ proxy.mailboxes = {
});
return;
}
msg.ctime = time || 0;
box.content[hash] = msg;
showMessage(ctx, type, message, null, function (obj) {
if (!obj || !obj.msg || !notify) { return; }

@ -73,7 +73,9 @@ define([
Common.openURL(Hash.hashToHref(userData.profile, 'profile'));
});
}
var order = -Math.floor((Util.find(data, ['content', 'msg', 'ctime']) || 0) / 1000);
notif = h('div.cp-notification', {
style: 'order:'+order+';',
'data-hash': data.content.hash
}, [
avatar,

Loading…
Cancel
Save