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
|
// Event delegation — read-more expands, see-less collapses
|
||||||
document.addEventListener('click', (e) => {
|
document.addEventListener('click', (e) => {
|
||||||
// Read more / See less
|
// Read more / See less
|
||||||
@@ -507,6 +517,7 @@
|
|||||||
if (ioSentinel) {
|
if (ioSentinel) {
|
||||||
container.appendChild(ioSentinel);
|
container.appendChild(ioSentinel);
|
||||||
}
|
}
|
||||||
|
attachMediaLoadListeners(container);
|
||||||
checkOverflow();
|
checkOverflow();
|
||||||
fetchSidebarYoutubeTitles(container);
|
fetchSidebarYoutubeTitles(container);
|
||||||
// Auto-play converted GIF videos
|
// Auto-play converted GIF videos
|
||||||
@@ -514,7 +525,7 @@
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SIDEBAR_PAGE_LIMIT = 50;
|
const SIDEBAR_PAGE_LIMIT = 5;
|
||||||
|
|
||||||
const loadActivity = async (silent = false) => {
|
const loadActivity = async (silent = false) => {
|
||||||
const container = document.getElementById('sidebar-activity-container');
|
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
|
// Keep the IO sentinel at the very end so it triggers on the next scroll
|
||||||
if (ioSentinel) container.appendChild(ioSentinel);
|
if (ioSentinel) container.appendChild(ioSentinel);
|
||||||
|
attachMediaLoadListeners(container);
|
||||||
checkOverflow();
|
checkOverflow();
|
||||||
fetchSidebarYoutubeTitles(container);
|
fetchSidebarYoutubeTitles(container);
|
||||||
// Auto-play converted GIF videos
|
// Auto-play converted GIF videos
|
||||||
@@ -661,6 +673,7 @@
|
|||||||
if (node) {
|
if (node) {
|
||||||
node.classList.add('new-item-fade');
|
node.classList.add('new-item-fade');
|
||||||
container.prepend(node);
|
container.prepend(node);
|
||||||
|
attachMediaLoadListeners(node);
|
||||||
checkOverflow();
|
checkOverflow();
|
||||||
fetchSidebarYoutubeTitles(container);
|
fetchSidebarYoutubeTitles(container);
|
||||||
}
|
}
|
||||||
@@ -701,6 +714,7 @@
|
|||||||
el.classList.remove('new-item-fade');
|
el.classList.remove('new-item-fade');
|
||||||
void el.offsetWidth;
|
void el.offsetWidth;
|
||||||
el.classList.add('new-item-fade');
|
el.classList.add('new-item-fade');
|
||||||
|
attachMediaLoadListeners(inner);
|
||||||
checkOverflow();
|
checkOverflow();
|
||||||
fetchSidebarYoutubeTitles(el);
|
fetchSidebarYoutubeTitles(el);
|
||||||
// Auto-play converted GIF videos
|
// Auto-play converted GIF videos
|
||||||
|
|||||||
Reference in New Issue
Block a user