Does not display unwanted archived notifications
This commit is contained in:
parent
b713b68e31
commit
fc9414b094
@ -26,14 +26,14 @@ define([
|
|||||||
var content = data.content;
|
var content = data.content;
|
||||||
var msg = content.msg;
|
var msg = content.msg;
|
||||||
|
|
||||||
// Check authenticity
|
|
||||||
if (msg.author !== msg.content.curvePublic) { return; }
|
|
||||||
|
|
||||||
// Display the notification
|
// Display the notification
|
||||||
content.getFormatText = function () {
|
content.getFormatText = function () {
|
||||||
return Messages._getKey('friendRequest_notification', [msg.content.displayName || Messages.anonymous]);
|
return Messages._getKey('friendRequest_notification', [msg.content.displayName || Messages.anonymous]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Check authenticity
|
||||||
|
if (msg.author !== msg.content.curvePublic) { return; }
|
||||||
|
|
||||||
// if not archived, add handlers
|
// if not archived, add handlers
|
||||||
if (!content.archived) {
|
if (!content.archived) {
|
||||||
content.handler = function () {
|
content.handler = function () {
|
||||||
|
|||||||
@ -44,12 +44,14 @@ define([
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var notifsAllowedTypes = ["FRIEND_REQUEST", "FRIEND_REQUEST_ACCEPTED", "FRIEND_REQUEST_DECLINED", "SHARE_PAD"];
|
||||||
|
|
||||||
var create = {};
|
var create = {};
|
||||||
|
|
||||||
var unreadData;
|
var unreadData;
|
||||||
|
|
||||||
// create the list of notifications
|
// create the list of notifications
|
||||||
// show only notifs with type in filterTypes array. If filterTypes empty, don't filter.
|
// show only notifs with type in filterTypes array
|
||||||
var makeNotificationList = function (key, filterTypes) {
|
var makeNotificationList = function (key, filterTypes) {
|
||||||
filterTypes = filterTypes || [];
|
filterTypes = filterTypes || [];
|
||||||
var safeKey = key.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
var safeKey = key.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
||||||
@ -77,16 +79,17 @@ define([
|
|||||||
// add notification
|
// add notification
|
||||||
var addNotification = function (data, el) {
|
var addNotification = function (data, el) {
|
||||||
// if the type of notification correspond
|
// if the type of notification correspond
|
||||||
if (filterTypes.length === 0 || filterTypes.indexOf(data.content.msg.type) !== -1) {
|
if (filterTypes.indexOf(data.content.msg.type) !== -1) {
|
||||||
notifsData.push(data);
|
notifsData.push(data);
|
||||||
$(notifsList).prepend(el);
|
$(notifsList).prepend(el);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var addArchivedNotification = function (data) {
|
var addArchivedNotification = function (data) {
|
||||||
|
// if the type is allowed
|
||||||
|
if (data.content.archived && notifsAllowedTypes.indexOf(data.content.msg.type) !== -1) {
|
||||||
var isDataUnread = unreadData.findIndex(function (ud) {
|
var isDataUnread = unreadData.findIndex(function (ud) {
|
||||||
return ud.content.hash === data.content.hash;
|
return ud.content.hash === data.content.hash;
|
||||||
}) !== -1;
|
}) !== -1;
|
||||||
if (data.content.archived) {
|
|
||||||
notifsData.push(data);
|
notifsData.push(data);
|
||||||
var el = common.mailbox.createElement(data);
|
var el = common.mailbox.createElement(data);
|
||||||
var time = new Date(data.content.time);
|
var time = new Date(data.content.time);
|
||||||
@ -105,7 +108,7 @@ define([
|
|||||||
$(dismissAll).remove();
|
$(dismissAll).remove();
|
||||||
loadmore = h("div.cp-app-notification-loadmore.cp-clickable", Messages.loadMore || "Load more ...");
|
loadmore = h("div.cp-app-notification-loadmore.cp-clickable", Messages.loadMore || "Load more ...");
|
||||||
$(loadmore).click(function () {
|
$(loadmore).click(function () {
|
||||||
common.mailbox.getNotificationsHistory('notifications', 5, lastKnownHash, function (err, messages) {
|
common.mailbox.getNotificationsHistory('notifications', 20, lastKnownHash, function (err, messages) {
|
||||||
// display archived notifs from most recent to oldest
|
// display archived notifs from most recent to oldest
|
||||||
for (var i = messages.length - 1 ; i >= 0 ; i--) {
|
for (var i = messages.length - 1 ; i >= 0 ; i--) {
|
||||||
var data = messages[i];
|
var data = messages[i];
|
||||||
@ -138,10 +141,9 @@ define([
|
|||||||
|
|
||||||
return $div;
|
return $div;
|
||||||
};
|
};
|
||||||
|
|
||||||
create['all'] = function () {
|
create['all'] = function () {
|
||||||
var key = 'all';
|
var key = 'all';
|
||||||
return makeNotificationList(key);
|
return makeNotificationList(key, notifsAllowedTypes);
|
||||||
};
|
};
|
||||||
|
|
||||||
create['friends'] = function () {
|
create['friends'] = function () {
|
||||||
@ -158,7 +160,7 @@ define([
|
|||||||
|
|
||||||
create['archived'] = function () {
|
create['archived'] = function () {
|
||||||
var key = 'archived';
|
var key = 'archived';
|
||||||
var filter = ["ARCHIVED"];
|
var filter = [];
|
||||||
return makeNotificationList(key, filter);
|
return makeNotificationList(key, filter);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user