mirror of https://github.com/xwiki-labs/cryptpad
Clear notifications viewed from another store (browser/worker)
This commit is contained in:
parent
7fd3bba2a6
commit
11a365557c
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue