Chat: disconnect IntersectionObserver (#14091)

This commit is contained in:
rhymes 2021-06-29 11:13:56 +02:00 committed by GitHub
parent 285462baac
commit c2a7038406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,7 +53,18 @@ export function setupObserver(callback) {
const somethingObserver = new IntersectionObserver(callback, {
threshold: [0, 1],
});
somethingObserver.observe(sentinel);
window.addEventListener('beforeunload', () => {
somethingObserver.disconnect();
});
if (typeof instantClick !== 'undefined') {
InstantClick.on('change', () => {
somethingObserver.disconnect();
});
}
}
export function hideMessages(messages, userId) {