hide multiple repeats of same notice

This commit is contained in:
Hannes Mannerheim 2016-01-17 00:21:30 +01:00
parent 35aad6a531
commit 95838ace25
3 changed files with 32 additions and 3 deletions

View File

@ -1706,6 +1706,7 @@ body.rtl #history-container.menu-container a .chev-right {
overflow:hidden; overflow:hidden;
} }
.stream-item.hidden, .stream-item.hidden,
.stream-item.hidden-repeat,
.stream-item.always-hidden { .stream-item.always-hidden {
display:none; display:none;
} }
@ -2023,7 +2024,7 @@ body.rtl .queet.rtl .expanded-content {
overflow: hidden; overflow: hidden;
} }
.quoted-notice:hover { .quoted-notice:hover {
text-decoration: none !important; text-decoration: none !important;
} }
.stream-item:hover:not(.expanded) .quoted-notice { .stream-item:hover:not(.expanded) .quoted-notice {
border: 1px solid #ddd; border: 1px solid #ddd;

View File

@ -718,6 +718,9 @@ function setNewCurrentStream(streamObject,setLocation,fallbackId,actionOnSuccess
}); });
} }
// hide dublicate repeats, only show the first/oldest instance of a notice
oldStreamState = hideAllButOldestInstanceOfStreamItem(oldStreamState);
// show full notice text for all cached notices, if we have it in cache // show full notice text for all cached notices, if we have it in cache
$.each(oldStreamState.children('.stream-item'),function(){ $.each(oldStreamState.children('.stream-item'),function(){
getFullUnshortenedHtmlForQueet($(this),true); getFullUnshortenedHtmlForQueet($(this),true);
@ -746,7 +749,7 @@ function setNewCurrentStream(streamObject,setLocation,fallbackId,actionOnSuccess
actionOnSuccess(); actionOnSuccess();
// make sure page-container is visible // make sure page-container is visible
$('#page-container').css('opacity','1'); $('#page-container').css('opacity','1');
// don't invoke actionOnSuccess later if we already invoked it here // don't invoke actionOnSuccess later if we already invoked it here
actionOnSuccess = false; actionOnSuccess = false;
@ -1773,6 +1776,12 @@ function addToFeed(feed, after, extraClasses) {
// if repeat-notice doesn't already exist in feed // if repeat-notice doesn't already exist in feed
if($('#stream-item-' + obj.id).length == 0) { if($('#stream-item-' + obj.id).length == 0) {
// if the repeated notice already exist in feed, we add this, but hidden
if($('.stream-item[data-quitter-id="' + obj.retweeted_status.id + '"]').length > 0) {
extraClassesThisRun += ' hidden-repeat';
}
var queetHtml = buildQueetHtml(obj.retweeted_status, obj.id, extraClassesThisRun, obj); var queetHtml = buildQueetHtml(obj.retweeted_status, obj.id, extraClassesThisRun, obj);
if(after) { if(after) {

View File

@ -343,7 +343,7 @@ function isLocalURL(url) {
· · · · · · · · · */ · · · · · · · · · */
function maybeShowTheNewQueetsBar() { function maybeShowTheNewQueetsBar() {
var new_queets_num = $('#feed-body').find('.stream-item.hidden:not(.always-hidden)').length; var new_queets_num = $('#feed-body').find('.stream-item.hidden:not(.always-hidden):not(.hidden-repeat)').length;
if(new_queets_num > 0) { if(new_queets_num > 0) {
$('#new-queets-bar').parent().removeClass('hidden'); $('#new-queets-bar').parent().removeClass('hidden');
@ -941,6 +941,7 @@ function rememberStreamStateInLocalStorage() {
var feed = $('<div/>').append(firstTwentyVisibleHTML); var feed = $('<div/>').append(firstTwentyVisibleHTML);
feed.find('.temp-post').remove(); feed.find('.temp-post').remove();
feed.children('.stream-item').removeClass('not-seen'); feed.children('.stream-item').removeClass('not-seen');
feed.children('.stream-item').removeClass('hidden-repeat'); // this means we need hide repeats when adding cached notices to feed later
feed.children('.stream-item').removeClass('selected-by-keyboard'); feed.children('.stream-item').removeClass('selected-by-keyboard');
feed.find('.dropdown-menu').remove(); feed.find('.dropdown-menu').remove();
feed.find('.stream-item').removeClass('expanded').removeClass('next-expanded').removeClass('hidden').removeClass('collapsing').addClass('visible'); feed.find('.stream-item').removeClass('expanded').removeClass('next-expanded').removeClass('hidden').removeClass('collapsing').addClass('visible');
@ -959,6 +960,24 @@ function rememberStreamStateInLocalStorage() {
} }
/* ·
·
· Hide all instances (repeats) of a notice but the first/oldest one
·
· @param streamItems: jQuery object with stream items as children
·
· · · · · · · · · */
function hideAllButOldestInstanceOfStreamItem(streamItemContainer) {
streamItemContainer.children('.stream-item').each(function(){
// if this stream item have siblings _after_ it, with the same id, hide it!
if($(this).nextAll('.stream-item[data-quitter-id="' + $(this).attr('data-quitter-id') + '"]').length > 0) {
$(this).addClass('hidden-repeat');
}
});
return streamItemContainer;
}
/* · /* ·