From 759e06216d868f6e8f3f76ef1509bafbc4933c5c Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Fri, 7 Nov 2014 16:27:13 -0200 Subject: [PATCH] display new mentions with a different background --- css/style.css | 4 ++++ js/twister_formatpost.js | 3 +++ js/twister_newmsgs.js | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/css/style.css b/css/style.css index 163e506..c185674 100644 --- a/css/style.css +++ b/css/style.css @@ -851,6 +851,10 @@ ol.toptrends-list { transition: background .1s linear; -moz-transition: background .1s linear; } +.post.new +{ + background: #F7F8E0; +} .post.open { margin: 10px 0; diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 87b6d16..f5c25cd 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -56,6 +56,9 @@ function postToElem( post, kind, promoted ) { elem.addClass(kind); elem.attr('data-time', t); + if( post["isNew"] ) + elem.addClass('new'); + var postData = elem.find(".post-data"); postData.addClass(kind); postData.attr('data-userpost', postJson); diff --git a/js/twister_newmsgs.js b/js/twister_newmsgs.js index 658a4a5..0924056 100644 --- a/js/twister_newmsgs.js +++ b/js/twister_newmsgs.js @@ -24,7 +24,8 @@ function processMention(user, mentionTime, data) { if( mentionTime + 3600 * 24 * 3 > _lastMentionTime ) { _newMentions++; newMentionsUpdated = true; - _lastMentionTime = mentionTime; + _lastMentionTime = Math.max(mentionTime,_lastMentionTime); + data["isNew"] = true; } _knownMentions[key] = {mentionTime:mentionTime, data:data}; purgeOldMentions(); @@ -80,6 +81,11 @@ function requestMentionsCount() { function resetMentionsCount() { _newMentions = 0; + for( var key in _knownMentions ) { + if( _knownMentions.hasOwnProperty(key) && _knownMentions[key].data ) { + delete _knownMentions[key].data["isNew"] + } + } saveMentionsToStorage(); $.MAL.updateNewMentionsUI(_newMentions); }