diff --git a/static/index.js b/static/index.js index 0712f67..12c3332 100644 --- a/static/index.js +++ b/static/index.js @@ -10,8 +10,9 @@ let currentItem = -1 // for newest listing let newMode = params.get('order') == 'new' -let endItem // for the later new items +let endItem // for the later new items. new items will be fetch until this item let maxItem +let new_loader_id // for the api requests let loadedItems = 0 @@ -59,6 +60,11 @@ function loadItems() { if (!shouldLoad()) { loader_id = clearInterval(loader_id) + + if (newMode && !new_loader_id) { + new_loader_id = setInterval(loadFresh, 5e3) + } + return } @@ -91,17 +97,17 @@ function getItem(id) { function makeItemListing(itemObj) { if (itemObj === null || itemObj === undefined) { - console.log(`[makeItemListing] null or undefined object`) clearInterval(loader_id) - return + throw new Error(`[makeItemListing] null or undefined object`) } if (itemObj.deleted || itemObj.dead || itemObj.title == "[deleted]") { - console.log(`[makeItemListing] bad item: ${itemObj.id}`) + console.debug(`[makeItemListing] Deleted item: ${itemObj.id}`) return } if (itemObj.type == itemType.comment || itemObj.type == itemType.pollopt) { + console.debug(`[makeItemListing] Comment or Poll Option item: ${itemObj.id}`) return } @@ -269,16 +275,16 @@ async function loadPollOpt(opts) { } const element_string =` -