Clear notifications viewed from another store (browser/worker)
This commit is contained in:
parent
7fd3bba2a6
commit
11a365557c
34
customize.dist/src/less2/include/notifications.less
Normal file
34
customize.dist/src/less2/include/notifications.less
Normal file
@ -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 = [];
|
box.queue = [];
|
||||||
};
|
};
|
||||||
cfg.onMessage = function (msg, user, vKey, isCp, hash, author) {
|
cfg.onMessage = function (msg, user, vKey, isCp, hash, author) {
|
||||||
|
if (hash === m.lastKnownHash) { return; }
|
||||||
try {
|
try {
|
||||||
msg = JSON.parse(msg);
|
msg = JSON.parse(msg);
|
||||||
console.log(msg);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
@ -153,9 +153,28 @@ proxy.mailboxes = {
|
|||||||
m.viewed.splice(toClean[i], 1);
|
m.viewed.splice(toClean[i], 1);
|
||||||
}
|
}
|
||||||
// Listen for changes in the "viewed" and lastKnownHash values
|
// Listen for changes in the "viewed" and lastKnownHash values
|
||||||
ctx.store.proxy.on('change', ['mailboxes', type], function () {
|
var view = function (h) {
|
||||||
// Check everything!
|
delete box.content[h];
|
||||||
// XXX
|
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
|
// Continue
|
||||||
onReady();
|
onReady();
|
||||||
|
|||||||
@ -32,14 +32,12 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
mailbox.sendTo = function (type, content, user) {
|
mailbox.sendTo = function (type, content, user) {
|
||||||
console.log(user, type, content);
|
|
||||||
execCommand('SENDTO', {
|
execCommand('SENDTO', {
|
||||||
type: type,
|
type: type,
|
||||||
msg: content,
|
msg: content,
|
||||||
user: user
|
user: user
|
||||||
}, function (err, obj) {
|
}, function (err, obj) {
|
||||||
if (err || (obj && obj.error)) { return void console.error(err || obj.error); }
|
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();
|
e.stopPropagation();
|
||||||
mailbox.dismiss(data, function (err) {
|
mailbox.dismiss(data, function (err) {
|
||||||
if (err) { return void console.error(err); }
|
if (err) { return void console.error(err); }
|
||||||
if (notif && notif.parentNode) {
|
/*if (notif && notif.parentNode) {
|
||||||
try {
|
try {
|
||||||
notif.parentNode.removeChild(notif);
|
notif.parentNode.removeChild(notif);
|
||||||
} catch (e) { console.error(e); }
|
} catch (e) { console.error(e); }
|
||||||
}
|
}*/
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
notif = h('div.cp-notification', {
|
notif = h('div.cp-notification', {
|
||||||
@ -76,6 +74,14 @@ define([
|
|||||||
var onViewedHandlers = [];
|
var onViewedHandlers = [];
|
||||||
var onMessageHandlers = [];
|
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
|
// Call the onMessage handlers
|
||||||
var pushMessage = function (data, handler) {
|
var pushMessage = function (data, handler) {
|
||||||
var todo = function (f) {
|
var todo = function (f) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user