Pārlūkot izejas kodu

Fix auto_remove_article (#2334)

* Fix auto_remove_article

https://github.com/FreshRSS/FreshRSS/issues/2323

* Second attempt

* Third attempt
Alexandre Alapetite 7 gadi atpakaļ
vecāks
revīzija
452419bf83
1 mainītis faili ar 9 papildinājumiem un 8 dzēšanām
  1. 9 8
      p/scripts/main.js

+ 9 - 8
p/scripts/main.js

@@ -590,23 +590,24 @@ function onScroll() {
 			});
 	}
 	if (context.auto_remove_article) {
-		let maxTop = box_to_follow.scrollTop,
-			scrollOffset = 0;
-		document.querySelectorAll('.flux:not(.active):not(.keep_unread)').forEach(function (div) {
+		let scrollTop = box_to_follow.scrollTop;
+		let dirty = false;
+		document.querySelectorAll('.flux:not(.active):not(.not_read)').forEach(function (div) {
 				if (!pending_entries[div.id] && div.offsetHeight > 0 &&
-					div.offsetParent.offsetTop + div.offsetTop + div.offsetHeight < maxTop) {
+					div.offsetParent.offsetTop + div.offsetTop + (div.offsetHeight * 2) < scrollTop) {
 					const p = div.previousElementSibling,
 						n = div.nextElementSibling;
 					if (p && p.classList.contains('day') && n && n.classList.contains('day')) {
+						scrollTop -= p.offsetHeight;
 						p.remove();
 					}
-					maxTop -= div.offsetHeight;
-					scrollOffset -= div.offsetHeight;
+					scrollTop -= div.offsetHeight;
 					div.remove();
+					dirty = true;
 				}
 			});
-		if (scrollOffset != 0) {
-			box_to_follow.scrollTop += scrollOffset;
+		if (dirty) {
+			box_to_follow.scrollTop = scrollTop;
 			return;	//onscroll will be called again
 		}
 	}