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;
}
.stream-item.hidden,
.stream-item.hidden-repeat,
.stream-item.always-hidden {
display:none;
}

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
$.each(oldStreamState.children('.stream-item'),function(){
getFullUnshortenedHtmlForQueet($(this),true);
@ -1773,6 +1776,12 @@ function addToFeed(feed, after, extraClasses) {
// if repeat-notice doesn't already exist in feed
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);
if(after) {

View File

@ -343,7 +343,7 @@ function isLocalURL(url) {
· · · · · · · · · */
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) {
$('#new-queets-bar').parent().removeClass('hidden');
@ -941,6 +941,7 @@ function rememberStreamStateInLocalStorage() {
var feed = $('<div/>').append(firstTwentyVisibleHTML);
feed.find('.temp-post').remove();
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.find('.dropdown-menu').remove();
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;
}
/* ·