show read more button for attachments in sidebar by default

This commit is contained in:
2026-05-17 11:39:51 +02:00
parent b2d836ffb1
commit a7b8f8f8e5

View File

@@ -1,4 +1,4 @@
(function() {
(function () {
let customEmojis = {};
let loading = false;
let loadingMore = false;
@@ -67,7 +67,7 @@
return data.meta;
}
}
} catch (e) {}
} catch (e) { }
return null;
})();
ytOembedPending.set(videoId, promise);
@@ -175,7 +175,7 @@
const urlToParse = href.startsWith('//') ? window.location.protocol + href : href;
const urlObj = new URL(urlToParse, siteOrigin);
isSameSite = (urlObj.hostname === window.location.hostname);
} catch(e) {}
} catch (e) { }
}
let displayText = text;
@@ -184,7 +184,7 @@
const urlToParse = href.startsWith('//') ? window.location.protocol + href : href;
const url = new URL(urlToParse.startsWith('http') ? urlToParse : siteOrigin + (urlToParse.startsWith('/') ? '' : '/') + urlToParse);
displayText = url.pathname + url.search + url.hash;
} catch (e) {}
} catch (e) { }
}
const isMention = href.startsWith('/user/') && text.startsWith('@');
@@ -195,8 +195,8 @@
};
renderer.image = function (href, title, text) {
const src = (typeof href === 'object' && href !== null) ? (href.href || '') : (href || '');
const alt = text || '';
const ttl = title ? ` title="${title}"` : '';
const alt = text || '';
const ttl = title ? ` title="${title}"` : '';
return `<img class="sidebar-comment-img" src="${src}" alt="${alt}"${ttl} loading="lazy">`;
};
@@ -206,8 +206,8 @@
if (trimmed.startsWith('>') && !trimmed.match(/^>>\d+/)) {
// Manual greentext handling — apply emoji if the user preference allows it
const quoteContent = line.substring(line.indexOf('>') + 1);
const quoteEmojis = window.f0ckSession?.quote_emojis === true;
const rendered = quoteEmojis
const quoteEmojis = window.f0ckSession?.quote_emojis === true;
const rendered = quoteEmojis
? quoteContent.replace(/:([a-z0-9_]+):/g, (m, n) => renderEmoji(m, n))
: quoteContent;
return `<span class="greentext">&gt;${rendered}</span>`;
@@ -316,7 +316,7 @@
const urlToParse = cleanUrl.startsWith('//') ? window.location.protocol + cleanUrl : cleanUrl;
const urlObj = new URL(urlToParse, siteOrigin);
isSameSite = (urlObj.hostname === window.location.hostname);
} catch(e) {
} catch (e) {
isSameSite = cleanUrl.startsWith(siteOrigin) || (cleanUrl.startsWith('/') && !cleanUrl.startsWith('//'));
}
const label = isSameSite ? 'Video Link' : 'External Video Link';
@@ -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
@@ -490,7 +500,7 @@
}
container.innerHTML = html;
// Auto-play converted GIF videos
container.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => {}), { once: true }); }); });
container.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => { }), { once: true }); }); });
};
const renderFromCache = () => {
@@ -507,14 +517,15 @@
if (ioSentinel) {
container.appendChild(ioSentinel);
}
attachMediaLoadListeners(container);
checkOverflow();
fetchSidebarYoutubeTitles(container);
// Auto-play converted GIF videos
container.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => {}), { once: true }); }); });
container.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => { }), { once: true }); }); });
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,10 +624,11 @@
}
// 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
container.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => {}), { once: true }); }); });
container.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => { }), { once: true }); }); });
}
} else {
hasMore = false;
@@ -656,11 +668,12 @@
if (container) {
const html = renderActivityItem(newItem);
const temp = document.createElement('div');
temp.innerHTML = html;
temp.innerHTML = html;
const node = temp.firstElementChild;
if (node) {
node.classList.add('new-item-fade');
container.prepend(node);
attachMediaLoadListeners(node);
checkOverflow();
fetchSidebarYoutubeTitles(container);
}
@@ -701,10 +714,11 @@
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
inner.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => {}), { once: true }); }); });
inner.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => { }), { once: true }); }); });
}
}
}