show read more button for attachments in sidebar by default
This commit is contained in:
@@ -441,6 +441,16 @@
|
||||
});
|
||||
};
|
||||
|
||||
const attachMediaLoadListeners = (element) => {
|
||||
element.querySelectorAll('img, video').forEach(media => {
|
||||
if (media.dataset.loadListenerBound) return;
|
||||
media.dataset.loadListenerBound = 'true';
|
||||
|
||||
media.addEventListener('load', checkOverflow, { once: true });
|
||||
media.addEventListener('loadedmetadata', checkOverflow, { once: true });
|
||||
});
|
||||
};
|
||||
|
||||
// Event delegation — read-more expands, see-less collapses
|
||||
document.addEventListener('click', (e) => {
|
||||
// Read more / See less
|
||||
@@ -507,6 +517,7 @@
|
||||
if (ioSentinel) {
|
||||
container.appendChild(ioSentinel);
|
||||
}
|
||||
attachMediaLoadListeners(container);
|
||||
checkOverflow();
|
||||
fetchSidebarYoutubeTitles(container);
|
||||
// Auto-play converted GIF videos
|
||||
@@ -514,7 +525,7 @@
|
||||
return true;
|
||||
};
|
||||
|
||||
const SIDEBAR_PAGE_LIMIT = 50;
|
||||
const SIDEBAR_PAGE_LIMIT = 5;
|
||||
|
||||
const loadActivity = async (silent = false) => {
|
||||
const container = document.getElementById('sidebar-activity-container');
|
||||
@@ -613,6 +624,7 @@
|
||||
}
|
||||
// Keep the IO sentinel at the very end so it triggers on the next scroll
|
||||
if (ioSentinel) container.appendChild(ioSentinel);
|
||||
attachMediaLoadListeners(container);
|
||||
checkOverflow();
|
||||
fetchSidebarYoutubeTitles(container);
|
||||
// Auto-play converted GIF videos
|
||||
@@ -661,6 +673,7 @@
|
||||
if (node) {
|
||||
node.classList.add('new-item-fade');
|
||||
container.prepend(node);
|
||||
attachMediaLoadListeners(node);
|
||||
checkOverflow();
|
||||
fetchSidebarYoutubeTitles(container);
|
||||
}
|
||||
@@ -701,6 +714,7 @@
|
||||
el.classList.remove('new-item-fade');
|
||||
void el.offsetWidth;
|
||||
el.classList.add('new-item-fade');
|
||||
attachMediaLoadListeners(inner);
|
||||
checkOverflow();
|
||||
fetchSidebarYoutubeTitles(el);
|
||||
// Auto-play converted GIF videos
|
||||
|
||||
Reference in New Issue
Block a user