diff options
author | Mario <mario@mariovavti.com> | 2025-06-10 08:46:01 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2025-06-10 08:46:01 +0000 |
commit | 4e01e212306e140bde8e9d3671f1edf6b1347bf6 (patch) | |
tree | 0571b1d0f412f9248bbe09174d750222cadf2596 /view/js | |
parent | 673790126bf0fa4a498b481fe4eacc509543c15c (diff) | |
download | volse-hubzilla-4e01e212306e140bde8e9d3671f1edf6b1347bf6.tar.gz volse-hubzilla-4e01e212306e140bde8e9d3671f1edf6b1347bf6.tar.bz2 volse-hubzilla-4e01e212306e140bde8e9d3671f1edf6b1347bf6.zip |
fix autoexpand iterations
Diffstat (limited to 'view/js')
-rw-r--r-- | view/js/main.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/view/js/main.js b/view/js/main.js index 609762da7..a05d95d3f 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -921,6 +921,9 @@ function updateConvItems(mode, data) { if (!elem.parentNode.parentNode.classList.contains('toplevel_item')) { elem.parentNode.parentNode.classList.add('item-highlight'); document.documentElement.style.setProperty('--hz-item-highlight', stringToHslColor(JSON.parse(elem.parentNode.parentNode.dataset.b64mids)[0])); + // Mark the comment button at the parent expanded + // TODO: should do that for all comments that have replies expanded + elem.parentNode.parentNode.querySelector('.wall-item-comment').classList.add('expanded'); } } @@ -1644,12 +1647,11 @@ const autoExpand = (function () { async function autoExpand(id) { const loading = document.getElementById('like-rotator-' + id); + let iteration = 0; + const maxIterations = 3; clickedElements.clear(); - maxIterations = 3; try { - let iteration = 0; - // Step 1: Ensure initial button is clicked const initBtnSelector = '#wall-item-comment-' + id; const initBtn = await waitForElement(initBtnSelector); @@ -1667,10 +1669,6 @@ const autoExpand = (function () { const commentBtnSelector = `#wall-item-sub-thread-wrapper-${id} .wall-item-comment`; do { - if (iteration >= maxIterations) { - return; - } - newButtonsFound = false; // Wait for any comment to appear @@ -1693,9 +1691,9 @@ const autoExpand = (function () { await new Promise(res => setTimeout(res, 700)); } - } while (newButtonsFound); + } while (newButtonsFound && iteration <= maxIterations); - console.log('All replies loaded!'); + console.log('Replies loaded!'); loading.style.display = 'none'; |