mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-15 21:05:56 +00:00
scroll handler: fix loadMoreHeadlines() not being called
This commit is contained in:
@@ -13,10 +13,6 @@ function resetCounterCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadMoreHeadlines() {
|
function loadMoreHeadlines() {
|
||||||
console.log("loadMoreHeadlines");
|
|
||||||
|
|
||||||
let offset = 0;
|
|
||||||
|
|
||||||
const view_mode = document.forms["main_toolbar_form"].view_mode.value;
|
const view_mode = document.forms["main_toolbar_form"].view_mode.value;
|
||||||
const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
|
const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
|
||||||
const num_all = $$("#headlines-frame > div[id*=RROW]").length;
|
const num_all = $$("#headlines-frame > div[id*=RROW]").length;
|
||||||
@@ -24,27 +20,25 @@ function loadMoreHeadlines() {
|
|||||||
|
|
||||||
// TODO implement marked & published
|
// TODO implement marked & published
|
||||||
|
|
||||||
if (view_mode == "marked") {
|
let offset = num_all;
|
||||||
console.warn("loadMoreHeadlines: marked is not implemented, falling back.");
|
|
||||||
offset = num_all;
|
switch (view_mode) {
|
||||||
} else if (view_mode == "published") {
|
case "marked":
|
||||||
console.warn("loadMoreHeadlines: published is not implemented, falling back.");
|
case "published":
|
||||||
offset = num_all;
|
console.warn("loadMoreHeadlines: ", view_mode, "not implemented");
|
||||||
} else if (view_mode == "unread") {
|
break;
|
||||||
offset = unread_in_buffer;
|
case "unread":
|
||||||
} else if (_search_query) {
|
offset = unread_in_buffer;
|
||||||
offset = num_all;
|
break;
|
||||||
} else if (view_mode == "adaptive" && !(getActiveFeedId() == -1 && !activeFeedIsCat())) {
|
case "adaptive":
|
||||||
// ^ starred feed shows both unread & read articles in adaptive mode
|
if (!(getActiveFeedId() == -1 && !activeFeedIsCat()))
|
||||||
offset = num_unread > 0 ? unread_in_buffer : num_all;
|
offset = num_unread > 0 ? unread_in_buffer : num_all;
|
||||||
} else {
|
break;
|
||||||
offset = num_all;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("offset: " + offset);
|
console.log("loadMoreHeadlines, offset=", offset);
|
||||||
|
|
||||||
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), offset: offset, infscroll_req: true});
|
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), offset: offset, infscroll_req: true});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_memory(root) {
|
function cleanup_memory(root) {
|
||||||
|
|||||||
@@ -1117,32 +1117,38 @@ function unpackVisibleHeadlines() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function headlinesScrollHandler(e) {
|
function headlinesScrollHandler(event) {
|
||||||
try {
|
try {
|
||||||
unpackVisibleHeadlines();
|
unpackVisibleHeadlines();
|
||||||
|
|
||||||
// set topmost child in the buffer as active
|
|
||||||
if (isCombinedMode() && getInitParam("cdm_expanded") && getInitParam("cdm_auto_catchup") == 1) {
|
|
||||||
|
|
||||||
const rows = $$("#headlines-frame > div[id*=RROW]");
|
if (isCombinedMode()) {
|
||||||
|
updateFloatingTitle();
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i++) {
|
// set topmost child in the buffer as active
|
||||||
const row = rows[i];
|
if (getInitParam("cdm_expanded") && getInitParam("cdm_auto_catchup") == 1) {
|
||||||
|
|
||||||
if ($("headlines-frame").scrollTop <= row.offsetTop &&
|
const rows = $$("#headlines-frame > div[id*=RROW]");
|
||||||
row.offsetTop - $("headlines-frame").scrollTop < 100 &&
|
|
||||||
row.getAttribute("data-article-id") != getActiveArticleId()) {
|
|
||||||
|
|
||||||
setActiveArticleId(row.getAttribute("data-article-id"));
|
for (let i = 0; i < rows.length; i++) {
|
||||||
break;
|
const row = rows[i];
|
||||||
|
|
||||||
|
if ($("headlines-frame").scrollTop <= row.offsetTop &&
|
||||||
|
row.offsetTop - $("headlines-frame").scrollTop < 100 &&
|
||||||
|
row.getAttribute("data-article-id") != getActiveArticleId()) {
|
||||||
|
|
||||||
|
setActiveArticleId(row.getAttribute("data-article-id"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_infscroll_disable) {
|
if (!_infscroll_disable) {
|
||||||
const hsp = $("headlines-spacer");
|
const hsp = $("headlines-spacer");
|
||||||
|
const container = $("headlines-frame");
|
||||||
|
|
||||||
if (hsp && hsp.offsetTop - 250 <= e.scrollTop + e.offsetHeight) {
|
if (hsp && hsp.offsetTop - 250 <= container.scrollTop + container.offsetHeight) {
|
||||||
|
|
||||||
hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
|
hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
|
||||||
__("Loading, please wait...") + "</span>";
|
__("Loading, please wait...") + "</span>";
|
||||||
@@ -1153,10 +1159,6 @@ function headlinesScrollHandler(e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCombinedMode()) {
|
|
||||||
updateFloatingTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getInitParam("cdm_auto_catchup") == 1) {
|
if (getInitParam("cdm_auto_catchup") == 1) {
|
||||||
|
|
||||||
let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]");
|
let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]");
|
||||||
|
|||||||
Reference in New Issue
Block a user