diff --git a/customize.dist/src/less2/include/notifications.less b/customize.dist/src/less2/include/notifications.less new file mode 100644 index 000000000..d65da5e49 --- /dev/null +++ b/customize.dist/src/less2/include/notifications.less @@ -0,0 +1,34 @@ +@import (reference) "./colortheme-all.less"; + +.notifications_main() { + --LessLoader_require: LessLoader_currentFile(); +} +& { + @notif-height: 50px; + .cp-notifications-container { + max-width: 300px; + display: flex; + flex-flow: column; + .cp-notification { + height: @notif-height; + display: flex; + .cp-notification-content { + flex: 1; + min-width: 0; + } + .cp-notification-dismiss { + color: black; + width: 25px; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + span { + cursor: pointer; + } + } + } + } +} + + diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index 2f5d84c00..a66fe55b7 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -112,9 +112,9 @@ proxy.mailboxes = { box.queue = []; }; cfg.onMessage = function (msg, user, vKey, isCp, hash, author) { + if (hash === m.lastKnownHash) { return; } try { msg = JSON.parse(msg); - console.log(msg); } catch (e) { console.error(e); } @@ -153,9 +153,28 @@ proxy.mailboxes = { m.viewed.splice(toClean[i], 1); } // Listen for changes in the "viewed" and lastKnownHash values - ctx.store.proxy.on('change', ['mailboxes', type], function () { - // Check everything! - // XXX + var view = function (h) { + delete box.content[h]; + ctx.emit('VIEWED', { + type: type, + hash: h + }, ctx.clients); + }; + ctx.store.proxy.on('change', ['mailboxes', type], function (o, n, p, r) { + if (p[2] === 'lastKnownHash') { + // Hide everything up to this hash + var sliceIdx; + box.history.some(function (h, i) { + sliceIdx = i + 1; + view(h); + if (h === n) { return true; } + }); + box.history = box.history.slice(sliceIdx); + } + if (p[2] === 'viewed') { + // Hide this message + view(n); + } }); // Continue onReady(); diff --git a/www/common/sframe-common-mailbox.js b/www/common/sframe-common-mailbox.js index 6179f55d8..4aca98e56 100644 --- a/www/common/sframe-common-mailbox.js +++ b/www/common/sframe-common-mailbox.js @@ -32,14 +32,12 @@ define([ }; mailbox.sendTo = function (type, content, user) { - console.log(user, type, content); execCommand('SENDTO', { type: type, msg: content, user: user }, function (err, obj) { if (err || (obj && obj.error)) { return void console.error(err || obj.error); } - console.log('notif sent to other user from inner'); }); }; @@ -56,11 +54,11 @@ define([ e.stopPropagation(); mailbox.dismiss(data, function (err) { if (err) { return void console.error(err); } - if (notif && notif.parentNode) { + /*if (notif && notif.parentNode) { try { notif.parentNode.removeChild(notif); } catch (e) { console.error(e); } - } + }*/ }); }); notif = h('div.cp-notification', { @@ -76,6 +74,14 @@ define([ var onViewedHandlers = []; var onMessageHandlers = []; + onViewedHandlers.push(function (data) { + var hash = data.hash.replace(/"/g, '\\\"'); + var $notif = $('.cp-notification[data-hash="'+hash+'"]'); + if ($notif.length) { + $notif.remove(); + } + }); + // Call the onMessage handlers var pushMessage = function (data, handler) { var todo = function (f) {